php Laravel ~ 属性 [控制器] 不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43572635/
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
php Laravel ~ Attribute [controller] does not exist
提问by cmiotk
I am trying to set up an Route Controller in my Laravel project and I have set up the controller and also the route.
我正在尝试在我的 Laravel 项目中设置一个路由控制器,并且我已经设置了控制器和路由。
However, when I load the route in the web.php
then it produces an error when I try to navigate to that page in the browser of Attribute [controller] does not exist
但是,当我在 中加载路由web.php
时,当我尝试在Attribute [controller] does not exist
Here is the code..
这是代码..
<?php
namespace CMS\Http\Controllers\Auth;
use CMS\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
use AuthenticatesUsers {
logout as performLogout;
}
/**
* Where to redirect users after login.
*
*/
protected $redirectTo;
/**
* Create a new controller instance.
*
*/
public function __construct()
{
$this->redirectTo = route('backend.dashboard');
$this->middleware('guest')->except('logout');
}
public function logout(Request $request)
{
$this->performLogout($request);
return redirect()->route('auth.login');
}
}
And then in the web.php I have this...
然后在 web.php 我有这个...
Route::controller('auth', 'Auth\LoginController', [
'getLogin' => 'auth.login'
]);
回答by R?sh?Kêsh Kümar
The controller method is deprecated since Laravel 5.3. But now, you can use the resource method, which is meant for the same purpose as the controller method.
自 Laravel 5.3 起不推荐使用控制器方法。但是现在,您可以使用资源方法,它的目的与控制器方法相同。
Like This:
像这样:
Route::resource('auth', 'LoginController');
or
或者
Route::get('/auth','LoginController');
Route::post('/auth','LoginController');