Laravel 5.3 This file vendorlaravelframeworksrcIlluminateFoundationAuthAuthenticatesUsers.php
has such a method:
protected function guard()
{
return Auth::guard(); //这个语句是什么意思?返回个什么值?
}
What does Auth::guard()
mean? What value is returned?
According to my understanding, each
Guard
represents a user group.In Laravel5.3, there is more complete support for multiple groups of users. We can have multiple groups of user systems, for example, there are one group of user systems in the frontend and one in the backend.
And what role does
Guard
play? Here is an exampleGenerally speaking, your
auth.php
configuration file will be configured with a default user group, usually users. When using users in the users group, you do not need to specify guard. When using other groups of users, you need to use guard to specify which group to use. user.Or you can look at the documentation and you may understand more.
Guard class 的源码
https://github.com/laravel/framework/blob/5.1/src/Illuminate/Auth/Guard.php