Laravel 4 URL::路由
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17937157/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 4 URL::route
提问by dynamitem
I've got an controller function that deletes an account. It's basically an route. I've read the manual and there is
我有一个删除帐户的控制器功能。基本上是一条路线。我已经阅读了手册,并且有
URL::route('name of the route');
URL::route('name of the route');
But how could I do it in the ?
但是我怎么能做到呢?
like input it in here:
喜欢在这里输入:
<td><a class="btn btn-mini btn-danger" href="the url goes here"><i class="icon-trash icon-white"></i> Delete</a></td>
回答by Laurence
You need to explicitly 'name' the routeif you want to call it by a route name:
如果你想通过路由名称调用它,你需要明确地“命名”路由:
Route::post('delete_character', array(
'as' => 'delete_character', // This is the route's name
'uses' => 'AuthController@delete_character'
));
回答by Hamid Naghipour
if you define Route name you can use that in your blade :
如果您定义路线名称,您可以在您的刀片中使用它:
define Route Name :
定义路由名称:
Route::get('/admin/transfer/forms-list', [
'as' => 'transfer.formsList',
'uses' => 'Website\TransferController@IndexTransferForms'
]);
now you can use that in your blade like this :
现在你可以像这样在你的刀片中使用它:
<a href="{{URL::route('transfer.formsList')}}" type="submit">
discard</a>
回答by Shiro
If you are using Blade Template Engine,
如果您使用的是刀片模板引擎,
Here is the solution:
这是解决方案:
<td><a class="btn btn-mini btn-danger" href="{{URL::route('controller.delete')}}"><i class="icon-trash icon-white"></i> Delete</a></td>