Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateUserRequest $request)
 {
     //
     $user = new User();
     $user->username = $request->username;
     $user->password = $request->password;
     $user->admin = $request->has('is_admin') ? $request->is_admin : 0;
     if ($user->save()) {
         return redirect()->route('console::users::index')->with('alert', ['type' => 'success', 'message' => 'User added.']);
     } else {
         return redirect()->route('console::users::create')->with('alert', ['type' => 'failure', 'message' => 'An error occurred, and the user could not be added.']);
     }
 }