I'm practicing laravel and im confused in querying relations I have two tables (users and roles)
in my user model i have
use SoftDeletes;
public function role(){
return $this->hasOne(Role::class);
}
and in my role model i have
use SoftDeletes;
public function user(){
return $this->belongsTo(User::class);
}
this is my table structure for role
and this my table structure for users
how can i query the roles base on users table
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire