【发布时间】:2017-06-28 07:21:17
【问题描述】:
我试图让用户只显示他们的报告。未通过身份验证的用户显示其他用户报告。但是,管理员可以显示所有用户报告。 我有这条路线:
Route::get('/showReport/{id}', 'CeciController@showReport');
我希望只有具有该报告 ID 的经过身份验证的用户和管理员才能访问此路由。如果我把它放在 auth 中间件组中,经过身份验证的用户可以访问其他用户报告。showReport/4,showReport/5,showReport/6。如果我把它放在管理中间件组下。即使是该 id 的经过身份验证的用户也无法访问它。如何实现?
查看:
Report for the month <b> {{$report->month}}: </b> <a href="{{url('/showReport', [$report->id])}}">Show Report Details</a>
这里是控制器:
public function showReport($id)
{
$report=Report::where('id',$id)->first();
if($report)
{
return view('show_report')->with('report',$report);
}
}
【问题讨论】:
标签: laravel laravel-5.3