Laravel将数据传递到路由 [英] Laravel passing the data to route
本文介绍了Laravel将数据传递到路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Laravel 5的新手,我无法解决简单的问题,因此我需要一些帮助.
I'm new in Laravel 5 and I need some help since I can't solve my simple problem.
我在 http://sample.com/partners 上有一个数据列表,如果我要单击我喜欢的数据链接将其重定向到
I have a list of data on http://sample.com/partners and if I will click the link of the data I like it to redirect it to
http://sample.com/partners/users/77 它将显示ID为77的有关用户的信息.
http://sample.com/partners/users/77 and it will display the information about the user with the id 77.
我无法提供路线和控制器,但这是我的partner.blade.php
I can't provide my route and controller but here is my partners.blade.php
@foreach ($data as $partners)
<tr bgcolor="#FF9999">
<td><a href="{{ $partners->partner_id }}"> {{ $partners->partner_id }} </a></td>
<td>{{$partners->name}}</td>
<td>{{$partners->address}}</td>
<td>{{$partners->tel_line_no}}</td>
</tr>
@endforeach
推荐答案
使用 url 或< a>
标记.
<a href="{{ url('partners/users', [$partners->partner_id]) }}">
{{ $partners->partner_id }}
</a>
这假定您在 routes.php
中有类似的内容:
This assumes you have something like this in your routes.php
:
Route::model('partner', App\Partner::class);
Route::get('/partners/users/{partner}', function(App\Partner $partner) {
view('show-partner', ['partner' => $partner]);
});
这篇关于Laravel将数据传递到路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文