im trying to show the data of authenticated user from his relation with other tables but can't get it to work, and im pretty new to laravel.
the user table has a relation with level table thru level_id, and the level table has a morph relation with the languages table, i'm trying to show the language of the level of the current user
here is my user model relation
public function level()
{
return $this->belongsTo(Level::class, 'level_id');
}
and my level model
public function languages()
{
return $this->morphMany(Language::class, 'langable');
}
and in the language table i need to get back the title of 0 or 1 like languages['0']title.
here is my controller
public function profile()
{
$user= User::with('level')->with('offers')->get();
return view('pages.user.index',compact('user'));
}
and here is how i got the auth user
{!! auth()->user()->first_name . ' ' . auth()->user()->last_name !!}
i'm trying to get this to work
but it's show me this
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire