// user model role relation
public function roles(): BelongsToMany
{
return $this->belongsToMany(Role::class)
->withPivot('id', 'assignable_type', 'assignable_id')
->withTimestamps();
}
// role model users relation
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class)
->withPivot('id', 'assignable_type', 'assignable_id')
->withTimestamps();
}
// user model role relation
public function roles(): BelongsToMany
{
return $this->belongsToMany(Role::class)
->withPivot('id', 'assignable_type', 'assignable_id')
->withTimestamps();
}
// role model users relation
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class)
->withPivot('id', 'assignable_type', 'assignable_id')
->withTimestamps();
}