Пример #1
0
 /**
  * Authenticate a user by username and password.
  *
  * @param string $username The username
  * @param string $password Plain text password
  * @return bool|user The user if the password matches the user's stored password, false otherwise.
  */
 public function authenticate($username, $password)
 {
     $user = User::where('username', $username)->first();
     if (!Hash::check($password, $user->password)) {
         return false;
     }
     return $user;
 }
 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     User::creating(function ($user) {
         if (isset($user->password)) {
             $user->password = Hash::make($user->password);
         }
     });
 }
Пример #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'])]);
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     return User::find($id);
 }
Пример #5
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function show($id)
 {
     $user = User::find($id);
     $questions = $user->answer;
     return $user;
 }