26 lines
614 B
PHP
26 lines
614 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Models;
|
||
|
|
||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||
|
|
||
|
class Permission extends Model
|
||
|
{
|
||
|
use HasFactory;
|
||
|
|
||
|
protected $fillable = [
|
||
|
'name'
|
||
|
];
|
||
|
|
||
|
/**
|
||
|
* Gets all the Roles with a relation with the Permission(Many to Many through role_has_permission)
|
||
|
* @return BelongsToMany
|
||
|
*/
|
||
|
public function roles(): BelongsToMany
|
||
|
{
|
||
|
return $this->belongsToMany(Role::class, "role_has_permission", "permission_id", "role_id")->withTimestamps();
|
||
|
}
|
||
|
}
|