Inverse of Relationship - Role belongs to many User

pull/3/head
Hasin Hayder 3 years ago
parent 259e224d6f
commit c670d6a2fe

@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\User;
class Role extends Model
{
@ -16,4 +17,8 @@ class Role extends Model
'created_at',
'updated_at',
];
public function users(){
return $this->belongsToMany(User::class,'user_roles');
}
}

Loading…
Cancel
Save