Laravel Breeze与Inertia和Vue结合使用,仪表板查看用户数据。

huangapple go评论57阅读模式
英文:

Laravel Breeze w/Inertia & Vue Dashboard view User Data

问题

我正在使用 Laravel 框架的 Breeze,结合 Inertia 和 Vue。

我正在查看我的 Vue Dev 工具,同时在仪表板视图中可以看到我的表格模式和用户的 strip ID。我想要更多地控制这里可以访问的内容,但是我找不到页面从哪里获取数据。我可以看到请求,甚至可以用 clockwork 看到查询,但是我找不到请求在代码中的位置。有人知道在哪里查找吗?Laravel Breeze与Inertia和Vue结合使用,仪表板查看用户数据。

英文:

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?Laravel Breeze与Inertia和Vue结合使用,仪表板查看用户数据。

答案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.

huangapple
  • 本文由 发表于 2023年8月9日 04:36:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76863056.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定