here's how my role and user model looks
// Role.php
public function user()
{
return $this->hasMany('App\Role');
}
// User.php
public function role()
{
return $this->belongsTo('App\User');
}
// get all users
$users = User::get();
foreach ($users as $user)
{
echo $user->role->name;
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community