英文:
Laravel Breeze w/Inertia & Vue Dashboard view User Data
问题
我正在使用 Laravel 框架的 Breeze,结合 Inertia 和 Vue。
我正在查看我的 Vue Dev 工具,同时在仪表板视图中可以看到我的表格模式和用户的 strip ID。我想要更多地控制这里可以访问的内容,但是我找不到页面从哪里获取数据。我可以看到请求,甚至可以用 clockwork 看到查询,但是我找不到请求在代码中的位置。有人知道在哪里查找吗?
英文:
I'm using Laravel with Breeze along with Inertia and Vue.
I am looking at my Vue Dev tool while on the dashboard view and I can see my table schema and the user's strip ID. I would like more control over what is accessible here, however, I cannot find where the page is getting the data from. I can see the request, and even the query with clockwork, but I can't find where the request is being made within the code. Does anyone know where to look?
答案1
得分: 1
auth.user
共享数据 来自于 这里,在 HandleInertiaRequests
中间件中。
public function share(Request $request): array
{
return array_merge(parent::share($request), [
'auth' => [
'user' => $request->user(),
],
'ziggy' => function () use ($request) {
return array_merge((new Ziggy)->toArray(), [
'location' => $request->url(),
]);
},
]);
}
这样可以在所有的 Inertia 响应中使用这些项目。
英文:
The auth.user
shared data comes from here, in the HandleInertiaRequests
middleware.
public function share(Request $request): array
{
return array_merge(parent::share($request), [
'auth' => [
'user' => $request->user(),
],
'ziggy' => function () use ($request) {
return array_merge((new Ziggy)->toArray(), [
'location' => $request->url(),
]);
},
]);
}
This makes these items available in all Inertia responses.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论