improvements
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\UserManagement\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
final class Permission extends Model
|
||||
{
|
||||
protected $table = 'user_management_permissions';
|
||||
|
||||
protected $fillable = ['name', 'slug', 'description'];
|
||||
|
||||
public function roles(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
Role::class,
|
||||
'user_management_permission_role',
|
||||
'permission_id',
|
||||
'role_id'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\UserManagement\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
final class Role extends Model
|
||||
{
|
||||
protected $table = 'user_management_roles';
|
||||
|
||||
protected $fillable = ['name', 'slug', 'description', 'is_system'];
|
||||
|
||||
protected $casts = ['is_system' => 'boolean'];
|
||||
|
||||
public function permissions(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
Permission::class,
|
||||
'user_management_permission_role',
|
||||
'role_id',
|
||||
'permission_id'
|
||||
);
|
||||
}
|
||||
|
||||
public function users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
User::class,
|
||||
'user_management_role_user',
|
||||
'role_id',
|
||||
'user_id'
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user