Can anyone help me convert this and help a noob learn the difference.
/**
* User Delete Account via Profile
*
* @access protected
* @return void
*
*/
protected function deleteProfile(Request $request) {
$this->validate($request, [
'confirmation' => 'required',
'password' => 'required',
]);
$usr = User::findOrFail(Auth::user()->id);
if (Hash::check($request->password, $usr->password)) {
Auth::logout();
// Removes UserID from Torrents if any and replaces with System UserID (0)
foreach(Torrent::where('user_id', '=', $usr->id)->get() as $tor) {
$tor->user_id = 0;
$tor->save();
}
// Removes UserID from Comments if any and replaces with System UserID (0)
foreach(Comment::where('user_id', '=', $usr->id)->get() as $com) {
$com->user_id = 0;
$com->save();
}
if($usr->delete()) {
return view('members.delete_account');
}
} else {
return redirect()->back()->with(Toastr::warning('Your Password Was Incorrect!', 'Error', ['options']));
}
}
This is set up to use Illuminate\Http\Request;
but i need it to work with Illuminate\Support\Facades\Request;
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2l4rzaB
via IFTTT
Aucun commentaire:
Enregistrer un commentaire