Skip to content

Commit

Permalink
PermissionRole MorphPivot model
Browse files Browse the repository at this point in the history
  • Loading branch information
fzldn committed Sep 16, 2024
1 parent 3e93d2f commit f82110f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Models/PermissionRole.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Models;

use App\Models\Traits\LogsModel;
use Illuminate\Database\Eloquent\Relations\MorphPivot;

class PermissionRole extends MorphPivot
{
use LogsModel;
}
10 changes: 10 additions & 0 deletions app/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ public function users(): BelongsToMany
{
return parent::users()->using(RoleUser::class);
}

/**
* The permissions that belong to the role.
*
* @return BelongsToMany<Permission>
*/
public function permissions(): BelongsToMany
{
return parent::permissions()->using(PermissionRole::class);
}
}

0 comments on commit f82110f

Please sign in to comment.