Refactor Auth config to use closures.
This commit is contained in:
@@ -4,29 +4,37 @@ return array(
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Authentication Model
|
| Retrieve Users By ID
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| This model will be used by the Auth class when retrieving the users of
|
| This method is called by the Auth::user() method when attempting to load
|
||||||
| your application. Feel free to change it to the name of your user model.
|
| a user by their user ID.
|
||||||
|
|
|
|
||||||
| Note: The authentication model must be an Eloquent model.
|
| You are free to change this method for your application however you wish.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'model' => 'User',
|
'by_id' => function($id)
|
||||||
|
{
|
||||||
|
return User::find($id);
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Authentication Username
|
| Retrieve Users By Username
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| The authentication username is the column on your users table that
|
| This method is called by the Auth::check() method when attempting to load
|
||||||
| is considered the username of the user. Typically, this is either "email"
|
| a user by their username.
|
||||||
| or "username". However, you are free to make it whatever you wish.
|
|
|
||||||
|
| You are free to change this method for your application however you wish,
|
||||||
|
| as long as you return an object that has "id" and "password" properties.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'username' => 'email',
|
'by_username' => function($username)
|
||||||
|
{
|
||||||
|
return User::where('email', '=', $username)->first();
|
||||||
|
},
|
||||||
|
|
||||||
);
|
);
|
||||||
Reference in New Issue
Block a user