30 lines
620 B
PHP
30 lines
620 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
|
|
#[Fillable(['name', 'description'])]
|
|
class Role extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* Get the users assigned to this role.
|
|
*/
|
|
public function users()
|
|
{
|
|
return $this->belongsToMany(User::class, 'role_user');
|
|
}
|
|
|
|
/**
|
|
* Get the apps/services assigned to this role.
|
|
*/
|
|
public function apps()
|
|
{
|
|
return $this->belongsToMany(App::class, 'app_role', 'role_id', 'app_id');
|
|
}
|
|
}
|