<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class PDFRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'code' => ['required', Rule::exists('residential_complexes', 'code')
                ->whereNull('deleted_at')],
        ];
    }

    public function all($keys = null)
    {
        $data = parent::all();
        $data['code'] = $this->route('code');

        return $data;
    }

    public function messages()
    {
        return [
            'slug.exists' => 'residential complex was not found'
        ];
    }
}
