update() 공개 메소드

public update ( Model $model, array $input ) : boolean
$model Illuminate\Database\Eloquent\Model
$input array
리턴 boolean
예제 #1
0
 public function update(Request $request, $id)
 {
     $data = $request->all();
     if (!$this->repository->update($id, $data)) {
         return $this->response(405, "Validation Errors", $this->repository->getErrors(), 200);
     }
     return $this->success('Updated Successfully.', $this->repository->getStoredObject());
 }
예제 #2
0
 /**
  * @param $id
  * @param array $data
  * @param array $roles
  * @return mixed
  */
 public function updateWithRoles($id, array $data, array $roles)
 {
     $user = $id;
     if (!$user instanceof User) {
         $user = $this->find($id);
     }
     $updated = parent::update($data, $id);
     if ($updated) {
         $user->detachAllRoles();
         collect($roles)->each(function ($role) use($user) {
             $user->attachRole($role);
         });
     }
     return $user;
 }