0👍
✅
One option is to pass $user
directly to component. In this case make sure to append role
data in user
model.
<example-component :user="{{ $user->toArray() }}"></example-component>
And then inside vue component you can print {{ user.role.name }}
You can also add an attribute in User.php
model and append it
protected $appends = ['role_name'];
public function getRoleNameAttribute()
{
return $this->role->name;
}
And then inside ExampleComponent
you can print {{ user.role_name }}
Source:stackexchange.com