0
I am a beginner on Laravel and I am trying to improve. I am trying to create a blog with 3 differents Roles.
I have a problem displaying my user's dashboard when registered. Apparently the users() method does not exist but it does exist in my role model.
screen of the error
database screen
role model
public function users(){
return $this->belongsToMany(User::class);
}
User Model
public function role(){
return $this->belongsTo(Role::class);
}
dashboard.blade.php
@if(Auth::users()->role->libelle =='admin');
@include('roles.admin')
@elsif(Auth::users()->role->libelle =='trainer');
@include('roles.trainer')
@elsif(Auth::users()->role->libelle =='user');
@include('roles.user')
@endif
user.blade.php
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Dashboard') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
You're logged in as user!
</div>
</div>
</div>
</div>
</x-app-layout>
0 comments:
Post a Comment
Thanks