/** * @param ProfileRequest $request * @param int $id * * @return mixed */ public function update(ProfileRequest $request, $id) { $User = User::find($id); if ($request->get('name')) { $User->name = $request->get('name'); } if ($request->get('email')) { $User->email = $request->get('email'); } if ($request->get('password') && env('APP_ENV') != 'homolog') { $User->password = bcrypt($request->get('password')); } if ($User->save()) { $this->flash()->success('Data has changed!'); } else { $this->flash()->error('Whooops! Could not change data.'); } return Redirect::back(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $User = User::find($id); if ($User->delete()) { return Redirect::back()->with('message', 'Successfully deleted record!')->with('message-class', 'success'); } else { return Redirect::back()->with('message', 'Whooops! Could not delete the record.')->with('message-class', 'error')->withInputs(); } }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $record = User::find($id); return view('back::scope.system.users.edit', compact('record')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $User = User::find($id); if (Gate::denies('delete', $User)) { return Redirect::route('back.system.users.index')->with('message', 'Not Allowed!')->with('message-class', 'danger'); } else { if ($User->delete()) { return Redirect::route('back.system.users.index')->with('message', 'Successfully deleted record!')->with('message-class', 'success'); } else { return Redirect::route('back.system.users.create')->with('message', 'Whooops! Could not delete the record.')->with('message-class', 'error'); } } }