我在routes.php文件中创建了路由
路线::控制器( 'AUTH', '验证\ AuthController');
Auth/AuthController.php文件是
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Guard;
use App\Http\Requests\Auth\LoginRequest;
use App\Http\Requests\Auth\RegisterRequest;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* the model instance
* @var User
*/
protected $user;
/**
* The Guard implementation.
*
* @var Authenticator
*/
protected $auth;
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct(Guard $auth, User $user)
{
$this->user = $user;
$this->auth = $auth;
$this->middleware('guest', ['except' => ['getLogout']]);
}
/**
* Show the application registration form.
*
* @return Response
*/
public function getRegister()
{
return view('auth.register');
}
/**
* Handle a registration request for the application.
*
* @param RegisterRequest $request
* @return Response
*/
public function postRegister(RegisterRequest $request)
{
//code for registering a user goes here.
$this->auth->login($this->user);
return redirect('/todo');
}
/**
* Show the application login form.
*
* @return Response
*/
public function getLogin()
{
return view('auth.login');
}
/**
* Handle a login request to the application.
*
* @param LoginRequest $request
* @return Response
*/
public function postLogin(LoginRequest $request)
{
if ($this->auth->attempt($request->only('email', 'password')))
{
return redirect('/todo');
}
return redirect('/login')->withErrors([
'email' => 'The credentials you entered did not match our records. Try again?',
]);
}
/**
* Log the user out of the application.
*
* @return Response
*/
public function getLogout()
{
$this->auth->logout();
return redirect('/');
}
}
Run Code Online (Sandbox Code Playgroud)
当我点击此身份验证/登录时,它会给我错误 - FileViewFinder.php第137行中的InvalidArgumentException:找不到视图[auth.login].任何人都可以帮我解决这个问题.
小智 6
如果您只是开始一个新项目,则没有开箱即用的身份验证视图,就像上面提到的Peter Fox一样。
您将需要输入
php artisan make:auth
Run Code Online (Sandbox Code Playgroud)
创建这些视图。
小智 5
当我们要进行全新设置时,可能会发生这种情况。先尝试清洁
php artisan view:clear
php artisan config:cache
php artisan route:cache
Run Code Online (Sandbox Code Playgroud)
i got mine to work after modifing the auth.login directroy from /Auth to /auth can be located at laravel/resources/views/Auth
| 归档时间: |
|
| 查看次数: |
17834 次 |
| 最近记录: |