<?php

namespace App\Http\Requests;

use App\Http\Controllers\Admin\UserManageTrait;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Foundation\Http\FormRequest;

class FormEventRegistrationDelete extends FormRequest
{
    use UserManageTrait;

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize(): bool
    {
        return $this->_canManage() || $this->_canEdit($this->route('id'));
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'id' => 'integer'
        ];
    }

    protected function failedAuthorization()
    {
        throw new AuthorizationException('You cannot delete this item.');
    }
}
