- Added `app_roles` migration to manage role assignments for connected apps, supporting role duration and indexing. - Introduced `AppRole` pivot model for managing `ConnectedApp` and `Role` relationships. - Updated `ConnectedApp` and `Role` models with `BelongsToMany` relationships for role associations. - Adjusted `permission` config to use custom `Role` model.
24 lines
480 B
PHP
24 lines
480 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Spatie\Permission\Models\Role as SpatieRole;
|
|
|
|
class Role extends SpatieRole
|
|
{
|
|
public function apps(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(
|
|
ConnectedApp::class,
|
|
'app_roles',
|
|
'role_id',
|
|
'app_id'
|
|
)
|
|
->using(AppRole::class)
|
|
->withPivot('id', 'duration');
|
|
}
|
|
}
|