Last active
September 23, 2016 02:52
-
-
Save Sarav-S/1d028bce8370a52d6316566d1601d812 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function save($request, $user = null) { | |
$status = "update"; | |
if (! $user) { | |
$user = new User; | |
$status = "create"; | |
} | |
$user->name = $request->input('name'); | |
$user->email = $request->input('email'); | |
if ($request->has('password')) { | |
$user->password = bcrypt($request->input('password')); | |
} | |
if ($user->save()) { | |
session()->flash('status', 'User '.$status.'d successfully'); | |
return redirect(route('users')); | |
} | |
session()->flash('status', 'Unable to '.$status.' user. Please try again'); | |
return back()->withInput(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment