- Replaced `AccessManager`, `Apps`, and `Settings` enums with modular enums like `RoleAndAppsPermissionEnum`, `AppPermissionEnum`, etc. - Updated route, view, Livewire components, and tests to use new modular enums. - Enhanced `DefaultRoleWithPermissionSeeder` and `PermissionSeeder` with updated enums. - Added README in the Enums/Permissions directory to explain usage and naming conventions. - Refactored dashboard sidebar and route definitions for better enum-based permission handling. - Improved test coverage to validate new permission enums functionality.
36 lines
824 B
PHP
36 lines
824 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Spatie\Activitylog\Models\Concerns\LogsActivity;
|
|
use Spatie\Activitylog\Support\LogOptions;
|
|
use Spatie\Permission\Models\Role as SpatieRole;
|
|
|
|
class Role extends SpatieRole
|
|
{
|
|
use LogsActivity;
|
|
|
|
public function apps(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(
|
|
ConnectedApp::class,
|
|
'app_roles',
|
|
'role_id',
|
|
'app_id'
|
|
)
|
|
->using(AppRole::class)
|
|
->withPivot('id', 'duration');
|
|
}
|
|
|
|
public function getActivitylogOptions(): LogOptions
|
|
{
|
|
return LogOptions::defaults()
|
|
->logOnly(['name', 'priority'])
|
|
->logOnlyDirty()
|
|
->useLogName('role_management');
|
|
}
|
|
}
|