这就是我的中间件的样子
public function share(Request $request): array
{
return array_merge(parent::share($request), [
'notifier' => fn() => session()->get('notifier'),
'request_filters' => fn() => request()->filter,
'media' => fn() => Media::query()
->when(request()->media_search, fn($q) => $q->search(request()->media_search))
->paginate(15),
'user_roles' => Auth::id() ? Auth::user()->getRoleNames() : [],
'actual_user' => fn() => session('actual_user') ?? null,
'company_pages' => fn() => Auth::id() ? Page::forCompany(Auth::company())->forType('page')->get() : [],
'primary' => 'test',
]);
}
现在我想选择“Primary”并将其显示在刀片模板中。我该怎么做?
错误是:未定义变量$primary
我试过了
{{$primary}}
您可以将primary添加到请求对象中。 并在任何地方检索它。
$request->primary = "test";