我想自定义内置的身份验证功能。也就是说,我想在内置的那个旁边添加一个Register表单。就像在这张图片上一样:
当我点击Registrieren Endkunde时,我会从laravel
获取内置表单我只是通过在同一个文件夹/resources/views/auth/registrieren-ag.blade.php中创建一个新文件来复制该视图文件register.blade.php,并且只更改了内部的一些内容,以便它说Registrieren新社。 但当我点击链接Registrieren Agentur的主页时,我收到此错误消息:
这是我的routes.php文件:
Route::get('/', function() {
return view('welcome');
});
Route::auth();
Route::get('/home', 'HomeController@index');
这些都是命令php artisan route:list
的所有路由+--------+----------+-------------------------+------+-----------------------------------------------------------------+------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+-------------------------+------+-----------------------------------------------------------------+------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | home | | App\Http\Controllers\HomeController@index | web,auth |
| | GET|HEAD | login | | App\Http\Controllers\Auth\AuthController@showLoginForm | web,guest |
| | POST | login | | App\Http\Controllers\Auth\AuthController@login | web,guest |
| | GET|HEAD | logout | | App\Http\Controllers\Auth\AuthController@logout | web |
| | POST | password/email | | App\Http\Controllers\Auth\PasswordController@sendResetLinkEmail | web,guest |
| | POST | password/reset | | App\Http\Controllers\Auth\PasswordController@reset | web,guest |
| | GET|HEAD | password/reset/{token?} | | App\Http\Controllers\Auth\PasswordController@showResetForm | web,guest |
| | GET|HEAD | register | | App\Http\Controllers\Auth\AuthController@showRegistrationForm | web,guest |
| | POST | register | | App\Http\Controllers\Auth\AuthController@register | web,guest |
+--------+----------+-------------------------+------+-----------------------------------------------------------------+------------+
现在,问题是如何在调用registrieren-ag.blade.php并添加功能时添加此路由?
答案 0 :(得分:0)
请显示方法showRegistrationForm并在Auth \ AuthController中注册,因为需要将return view('register');
更改为return view('registrieren-ag');
答案 1 :(得分:0)
Route :: auth()是定义以下路径的快捷方式:
$this->get('login', 'Auth\AuthController@showLoginForm');
$this->post('login', 'Auth\AuthController@login');
$this->get('logout', 'Auth\AuthController@logout');
$this->get('register', 'Auth\AuthController@showRegistrationForm');
$this->post('register', 'Auth\AuthController@register');
$this->get('password/reset/{token?}', 'Auth\PasswordController@showResetForm');
$this->post('password/email', 'Auth\PasswordController@sendResetLinkEmail');
$this->post('password/reset', 'Auth\PasswordController@reset');
答案 2 :(得分:0)
在这个方法中
public function showRegistrationForm()
{
if (property_exists($this, 'registerView')) {
return view($this->registerView);
}
return view('auth.register');
}
您需要将return view('auth.register');
更改为return view('auth.registrieren-ag');
答案 3 :(得分:0)
我刚删除所有内容并从头开始(现在新的注册表单名为registrieren.blade.php)我所做的只是在routes.php文件中添加了一条新路由:
Route::get('/registrieren', function() {
return view('auth.registrieren');
});
它可以打开它...我只需要测试它,如果它真的通过该表单注册用户!
它有效...我刚试过它! Sooo添加额外寄存器表单的解决方案:
转到/resources/views/layouts/app.blade.php并找到
<!-- Authentication Links -->
@if (Auth::guest())
<li><a href="{{ url('/login') }}">Login</a></li>
<li><a href="{{ url('/register') }}">Register</a></li>
@else
为新创建的注册表单添加新链接,例如:
<li><a href="{{ url('/registernew') }}">Register NEW</a>
记住这个名字&#39; registernew&#39;必须与重复的表单视图(registernew.blade.php)相同
在新表单视图中注册registernew.blade.php更改行
<div class="panel-heading">Register</div>
这应该是它....你可以添加新的表单字段并自定义数据库表以对应于那些表单字段,并且您可以在同一个表中使用不同的用户并将其用作角色!