Skip to content

Commit

Permalink
permission pivot model
Browse files Browse the repository at this point in the history
  • Loading branch information
fzldn committed Sep 17, 2024
1 parent 4f8dacb commit 5990c1e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/Models/RoleUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@ public function role(): BelongsTo
return $this->belongsTo(Role::class);
}

/**
* @return MorphTo
*/
public function model(): MorphTo
{
return $this->morphTo();
}

/**
* @return MorphTo<User>
*/
public function user(): MorphTo
{
return $this->morphTo('model');
return $this->model()->whereHasMorph('model', [User::class]);
}
}

0 comments on commit 5990c1e

Please sign in to comment.