gpt4 book ai didi

php - Laravel 链接到路由未定义

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:05:31 25 4
gpt4 key购买 nike

我正在对 profile Controller 进行分组,我想链接到它。然后我定义这条路线:

//Group to put all the routes that need login first
Route::group(array('prefix'=> 'admin', 'before' => 'csrf'), function(){
Route::resource('/profile' , 'ProfileController', array('as'=>'profile') );
});

这是我的菜单链接:

<li><a href="{{ URL::route('admin.profile') }}">profile Managment</a></li>

这是我在终端中 route 的结果:

+--------+----------------------------------+------------------------+---------------------------+----------------+---------------+
| Domain | URI | Name | Action | Before Filters | After Filters |
+--------+----------------------------------+------------------------+---------------------------+----------------+---------------+
| | GET / | index | Closure | | |
| | GET admin/index | dashboard | Closure | | |
| | GET logout | logout | Closure | | |
| | POST auth | auth | Closure | csrf | |
| | GET login | login | Closure | | |
| | GET admin/profile | admin..profile.index | ProfileController@index | csrf | |
| | GET admin/profile/create | admin..profile.create | ProfileController@create | csrf | |
| | POST admin/profile | admin..profile.store | ProfileController@store | csrf | |
| | GET admin/profile/{profile} | admin..profile.show | ProfileController@show | csrf | |
| | GET admin/profile/{profile}/edit | admin..profile.edit | ProfileController@edit | csrf | |
| | PUT admin/profile/{profile} | admin..profile.update | ProfileController@update | csrf | |
| | PATCH admin/profile/{profile} | | ProfileController@update | csrf | |
| | DELETE admin/profile/{profile} | admin..profile.destroy | ProfileController@destroy | csrf | |
+--------+----------------------------------+------------------------+---------------------------+----------------+---------------+

现在我得到这个错误:

ErrorException

Route [admin.profile] not defined. (View: /var/www/alachiq/app/views/back_end/menu.blade.php) (View: /var/www/alachiq/app/views/back_end/menu.blade.php) (View: /var/www/alachiq/app/views/back_end/menu.blade.php)

最佳答案

Route::resource 方法中删除 / 字符。它导致双点,这反过来又导致您的错误消息。

应该是:

Route::resource('profile' , 'ProfileController', array('as'=>'profile') );

格式(/profileprofile)通常都可以,但是当使用 prefix 选项和 Route::group 时 您需要从资源 URL 中删除 /

编辑:另外,在我看来,您应该将链接指向路线 admin.profile.index,而不是 admin.profile .

关于php - Laravel 链接到路由未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21623400/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com