【发布时间】:2018-06-03 01:06:09
【问题描述】:
例如,目前我有一张包含“律师”列表的表格。我可以在路线/网络中按州显示律师名单:
// Lawyers per state
Route::get('/lawyers/{state}', function ($state) {
$states = DB::table('states')->get();
$lawyers = DB::table('lawyers')->join('states', 'states.abbr', '=', 'lawyers.state')
->where('states.abbr', '=', $state)
->orderBy('lawyers.featured', 'desc')
->get(['lawyers.*', 'states.name AS state_name']);
$statename = DB::table('states')->where('abbr', $state)->value('name');
return view('pages.lawyers', ['lawyers' => $lawyers, 'states' => $states, 'statename' => $statename]);
});
这正确显示了律师名单。
我想要为每个律师创建一个唯一的 URL,例如具有 URL 结构 /lawyers/{state}/{firstname}-{lastname}-{zipcode} 的个人资料页面视图,因此在列表中单击他们的姓名会转到律师个人资料。
实现这一点的正确方法是:
- 律师网址显示
lawyers.profile视图 - 列表中的律师姓名链接到正确的 URL
谢谢!
【问题讨论】: