- Replaced `duration` (integer, days) with `validUpto` (datetime) in role-app assignments. - Updated `AssignAppsToRoleData`, `AppRole` model, and Livewire forms to adopt the new `validUpto` field. - Adjusted database migrations and UI components to reflect the change in validity representation. - Enhanced validity date inputs with support for "Unlimited" roles using toggles.
40 lines
836 B
PHP
40 lines
836 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\{Relations\BelongsTo, Relations\Pivot};
|
|
use Spatie\Permission\Models\Role;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property int $app_id
|
|
* @property int $role_id
|
|
* @property string $duration Validity of the role
|
|
*/
|
|
#[Fillable(['app_id', 'role_id', 'duration'])]
|
|
class AppRole extends Pivot
|
|
{
|
|
public $timestamps = false;
|
|
|
|
protected $table = 'app_roles';
|
|
|
|
/**
|
|
* @return BelongsTo<ConnectedApp, $this>
|
|
*/
|
|
public function app(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ConnectedApp::class, 'app_id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Role, $this>
|
|
*/
|
|
public function role(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Role::class, 'role_id');
|
|
}
|
|
}
|