Reputation: 1871
I'm using Laravel 5.4 with Vue.js 2.0. Is it possible to use Auth::user()
in a VueJS template?
For example...
<template>
<p>{{ Auth::user()->name }}</p>
</template>
export default {}
How can I achieve this?
Upvotes: 1
Views: 4964
Reputation: 443
You can pass the User instance into the component with a prop. For example:
<example-component :user="{{ Auth::user() }}"></example-component>
Then you can access the user's information like so:
<template>
<p>{{ user.name }}</p>
</template>
export default {
props : ['user']
}
Upvotes: 4