Laravel 5.4,如何找到 LoginController@showLoginForm?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44173616/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5.4, how do I find LoginController@showLoginForm?
提问by Simon Suh
in php artisan route:list I have
在 php artisan route:list 我有
GET|HEAD | login | login | App\Http\Controllers\Auth\LoginController@showLoginForm | web,guest
but when I go to App\Http\Controllers\Auth\LoginController.php all I have is the following. How do I find the '@showLoginForm' portion so I can edit this controller?
但是当我去 App\Http\Controllers\Auth\LoginController.php 时,我只有以下内容。如何找到“@showLoginForm”部分以便我可以编辑此控制器?
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}
回答by Muhammad Inaam Munir
In LoginController, you can see the following code:
在LoginController 中,您可以看到以下代码:
use AuthenticatesUsers;
Above line indicates that this class/controller (LoginController) is using AuthenticatesUsersTrait. And path of this trait is \vendor\laravel\framework\src\Illuminate\Foundation\Auth\AuthenticatesUsers.php
上面的行表示这个类/控制器(LoginController)正在使用AuthenticatesUsersTrait。这个特征的路径是\vendor\laravel\framework\src\Illuminate\Foundation\Auth\AuthenticatesUsers.php
In this trait file, first function is showLoginForm().
在这个特征文件中,第一个函数是showLoginForm()。
回答by Reiah Paul Sam
You can see
你可以看到
use AuthenticatesUsers;
AuthenticateUsers
is a Trait in Laravel which resides in /path/to/root/vendor/laravel\framework\src\Illuminate\Foundation\Auth
.
AuthenticateUsers
是 Laravel 中的一个 Trait,它驻留在/path/to/root/vendor/laravel\framework\src\Illuminate\Foundation\Auth
.
Traits in PHP is nothing but similar to interfaces, you can override the same method or variables where you include it or the same methods are variables in trait will take control.
PHP 中的 Traits 与接口类似,您可以覆盖包含它的相同方法或变量,或者相同的方法由 trait 中的变量控制。
if you want to override the method for some additional functionality just write a method with same method name inside LoginController
and implement your own logic. so the later one will work.
如果您想为某些附加功能覆盖该方法,只需在内部编写一个具有相同方法名称的方法LoginController
并实现您自己的逻辑。所以后者会起作用。