<?php

namespace App\Models;

use App\Models\Concerns\Auditable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class UserPermission extends Model
{
    use Auditable;

    protected $fillable = ['user_id', 'permission_id', 'effect', 'granted_by', 'expires_at'];

    protected function casts(): array
    {
        return ['expires_at' => 'datetime'];
    }

    public function permission(): BelongsTo { return $this->belongsTo(Permission::class); }
}
