【问题标题】:Move folder Auth in custom folder Admin and use the views with Laravel在自定义文件夹 Admin 中移动文件夹 Auth 并将视图与 Laravel 一起使用
【发布时间】:2016-07-30 02:25:08
【问题描述】:

我想在我的自定义文件夹 Admin 中移动 Auth 文件夹。

我创建了身份验证部分:

php artisan make:auth

我将文件夹 Auth 移动到我的 Admin 文件夹 (Views/Admin/Auth) 中

现在我的路径 mysite.com/admin/login 出现错误:

未找到查看 [auth.login]。

我想使用 admin.auth.login 视图

routes.php

Route::group(['middleware' => ['web'], 'prefix' => 'admin'], function () {
    Route::get('login', 'Auth\AuthController@showLoginForm');
    Route::post('login', 'Auth\AuthController@login');
    Route::get('logout', 'Auth\AuthController@logout');

    Route::get('register', 'Auth\AuthController@showRegistrationForm');
    Route::post('register', 'Auth\AuthController@register');

    Route::get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
    Route::post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
    Route::post('password/reset', 'Auth\PasswordController@reset');

    Route::get('dashboard',['as' => 'dashboard', 'uses' => 'AdminIndexController@index']);
});

如何修改视图路径?

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    只需将下面的代码放入您的AuthController

    protected $loginView = 'admin.auth.login';
    protected $registerView = 'admin.auth.register';
    

    您还需要将下面的代码放入PasswordController:

    protected $linkRequestView = 'admin.auth.passwords.email';
    protected $resetView = 'admin.auth.passwords.reset';
    

    基本上,laravel 在后台检查您是否为视图定义了自定义路径并在找到时使用它。

    【讨论】:

    • 谢谢!!我在未找到 View [auth.emails.password] 时遇到错误。但它已通过 app/config/auth.php 修复并修改了 'email' => 'admin.auth.emails.password' 部分,
    • 这个建议也解决了我的问题。我想知道你是如何找到这个解决方案的,因为我在文档中找不到像 $loginView 这样的东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-08
    • 2019-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多