public function createUser(Request $request)
 {
     if (!$this->checkRights()) {
         return redirect('/')->with('error', 'Access denied.');
     }
     $this->validate($request, ['name' => 'required|max:255', 'email' => 'required|max:255|email|unique:users,email', 'pass' => 'required|min:8']);
     $name = $request->name;
     $email = $request->email;
     $pass = bcrypt($request->pass);
     $rights = $request->rights == null ? 0 : 1;
     $data = ['name' => $name, 'email' => $email, 'password' => $pass, 'rights' => $rights];
     User::create($data);
     return redirect('admin')->with('status', 'Account ""' . $email . '" was created!');
 }
Пример #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::create(['email' => '*****@*****.**', 'name' => 'admin', 'password' => bcrypt('admin'), 'rights' => 1]);
     User::create(['email' => '*****@*****.**', 'name' => 'user', 'password' => bcrypt('user'), 'rights' => 0]);
 }
Пример #3
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }