Reputation: 133
I am currently working on a Laravel 8 project and for the first time, I tried using the provided Laravel Breeze scaffolding with Inertia.js and Vue. In the original dashboard scaffolding, the dashboard component can automatically retrieve the $page.props.auth.user
object, as shown in the image:
However, if you look at the <script>
part of the Vue component, the props for these objects aren't there.
My question is, how does Laravel pass the auth
object to the $page
variable?
I am not sure if my purpose will further help in answering that question, but I'm gonna say it anyway: I have made a polymorphic relationship between two models (a User
model and a Student
model) and I wanted the auth.user
object to also contain information from the associated row in Student
every request, since I'm gonna use it to display names and other details on a sidebar/navbar.
Thank you in advance for all your help!
Upvotes: 0
Views: 3424
Reputation: 9
Inside
app\Http\Middleware\HandleInertiaRequests.php
in
share
function
Upvotes: 0
Reputation: 6105
The $page.props.auth.user
comes from the share
method at \app\Http\Middleware\HandleInertiaRequests.php
middleware.
I've explained a little bit about this middleware on another answer you can read here.
You won't see the prop on the page component because it's a shared property. Give a closer look at the docs on this.
Upvotes: 3