public function update(EntityContract $entity, $parameters, $permission = Tokens::PERMISSION_UPDATE)
    {
        $parameters = $this->castParameters($parameters);

        $result = new Result();

        try {
            DB::beginTransaction();

            $result->addErrors($this->getAuthorizer()->authorize($permission, $entity, $parameters));

            if ($result->ok()) {
                $result->addErrors($this->getValidator()->validate($entity, $parameters));
            }

            if ($result->ok()) {
                $result->addErrors($this->fill($entity, $parameters)->getErrors());
            }

            if ($result->ok()) {
                $result->addErrors($this->save($entity)->getErrors());
            }

            if (!$result->ok()) {
                DB::rollBack();

                return $result;
            }

            $result->getResources()->push($entity);

            DB::commit();
        } catch (Exception $e) {
            DB::rollBack();

            throw $e;
        }

        return $result;
    }
public function update(EntityContract $entity, $parameters, $permission = Tokens::PERMISSION_UPDATE)
    {
        $parameters = $this->castParameters($parameters);

        $result = new Result();

        try {
            DB::beginTransaction();

            $result->addErrors($this->getAuthorizer()->authorize($permission, $entity, $parameters));

            if ($result->ok()) {
                $result->addErrors($this->getValidator()->validate($entity, $parameters));
            }

            if ($result->ok()) {
                $result->addErrors($this->fill($entity, $parameters)->getErrors());
            }

            if ($result->ok()) {
                $result->addErrors($this->save($entity)->getErrors());
            }

            if (!$result->ok()) {
                DB::rollBack();

                return $result;
            }

            $result->getResources()->push($entity);

            DB::commit();
        } catch (Exception $e) {
            DB::rollBack();

            throw $e;
        }

        return $result;
    }
public function update ( EntityContract $ entity , $ parameters , $ permission = Tokens :: PERMISSION_UPDATE ) { $ parameters = $ this -> castParameters ( $ parameters ) ; $ result = new Result ( ) ; try { DB :: beginTransaction ( ) ; $ result -> addErrors ( $ this -> getAuthorizer ( ) -> authorize ( $ permission , $ entity , $ parameters ) ) ; if ( $ result -> ok ( ) ) { $ result -> addErrors ( $ this -> getValidator ( ) -> validate ( $ entity , $ parameters ) ) ; } if ( $ result -> ok ( ) ) { $ result -> addErrors ( $ this -> fill ( $ entity , $ parameters ) -> getErrors ( ) ) ; } if ( $ result -> ok ( ) ) { $ result -> addErrors ( $ this -> save ( $ entity ) -> getErrors ( ) ) ; } if ( ! $ result -> ok ( ) ) { DB :: rollBack ( ) ; return $ result ; } $ result -> getResources ( ) -> push ( $ entity ) ; DB :: commit ( ) ; } catch ( Exception $ e ) { DB :: rollBack ( ) ; throw $ e ; } return $ result ; }
Update a EntityContract given parameters.

@param \Railken\Lem\Contracts\EntityContract $entity
@param Bag|array                             $parameters
@param string                                $permission

@return ResultContract
Update a EntityContract given parameters .