【发布时间】:2016-07-29 22:41:29
【问题描述】:
是否可以在路由绑定中访问经过身份验证的用户。
Route::bind('account', function($account_id)
{
dd(auth()->user()); // it's null :(
$account = App\Models\Account::where('business_id', auth()->user()->business_id)
->where('account_id', $account_id)
->first()
return !is_null($account) ? $account : App::abort(404);
});
我尝试在一些身份验证中间件中对路由绑定进行分组,没有骰子 - 这是一回事吗?避免在控制器中进行额外验证会非常有用。
帮助表示赞赏。
【问题讨论】: