<?php

namespace App\Models;

use App\Enums\AccessRequestStatus;
use Illuminate\Database\Eloquent\Concerns\HasUlids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class AccessRequests extends Model
{
    use HasUlids;

    public $incrementing = false;

    protected $keyType = 'string';

    protected $fillable = [
        'status',
        'game_username',
        'message',
        'server_id',
        'reviewed_by',
        'reviewed_at',
    ];

    public function reviewedBy(): BelongsTo
    {
        return $this->belongsTo(User::class, 'reviewed_by');
    }

    public function server(): BelongsTo
    {
        return $this->belongsTo(GameServers::class, 'server_id');
    }

    protected function casts(): array
    {
        return [
            'id' => 'string',
            'reviewed_at' => 'datetime',
            'status' => AccessRequestStatus::class,
        ];
    }
}
