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()); }
/** * @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; }