- Added `priority` column to `roles` table with migration and model updates. - Introduced priority management methods in `RoleService` and validation logic for updates. - Enhanced access-manager UI to display and edit role priorities via a modal. - Updated related data classes and views to support and handle the new priority field.
43 lines
999 B
PHP
43 lines
999 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Spatie\Activitylog\Models\Concerns\LogsActivity;
|
|
use Spatie\Activitylog\Support\LogOptions;
|
|
use Spatie\Permission\Models\Role as SpatieRole;
|
|
|
|
/**
|
|
* @property int $priority
|
|
* @property AppRole $pivot
|
|
* @property ConnectedApp $apps
|
|
*/
|
|
#[Fillable(['priority'])]
|
|
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');
|
|
}
|
|
}
|