我是Laravel的新手,我听说Laravel中的登录和注册系统是默认的。但是,我无法利用它。我在login / views /.
中的Auth目录中放置了登录和注册视图 我在Auth/AuthController.php
中有这个控制器:
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
private $redirectTo = '/loginpage';
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}
路线是:
// Authentication routes...
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
// Registration routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
但我收到此错误:
AuthenticatesAndRegistersUsers.php第11行中的FatalErrorException:A 优先规则是为。定义的 Illuminate \ Foundation \ Auth \ AuthenticatesUsers :: getGuard但是这个 方法不存在
答案 0 :(得分:0)
如果你正在使用larave 5.2 Ssh进入你的目录,然后输入
php artisan make:auth
(这是在项目开始时完成的,因为它可以覆盖一些视图)。还要确保已连接到数据库