<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class UpdateStatusRequest extends FormRequest
{
    public function authorize(): bool
    {
        $permission = match ($this->route()?->getName()) {
            'admin.master.academic-terms.update_status' => 'update-academic-terms-status',
            'admin.users.lecturers.update_user_status' => 'update-lecturers-status',
            'admin.users.students.update_user_status' => 'update-students-account-status',
            'admin.users.administrators.update_user_status' => 'update-administrators-status',
            default => null,
        };

        return $permission !== null && $this->user()->can($permission);
    }

    public function rules(): array
    {
        return [
            'is_active' => ['required', 'boolean'],
        ];
    }
}
