<?php

namespace App\Http\Requests;

use App\Models\Setup;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\Rule;

class AreafixRequest extends FormRequest
{
	public function authorize()
	{
		return Gate::allows('admin');
	}

	public function rules(Request $request)
	{
		if (! $request->isMethod('post'))
			return [];

		return [
			'to' => [
				'required',
				Rule::in(config('fido.areafilefix')),
			],
			'fftn_id' => [
				'required',
				Rule::in(our_address()->pluck('id')),
			],
			'tftn_id' => [
				'required',
				Rule::in($this->route('o')->akas->pluck('id')),
			],
			'subject' => 'required|min:1|max:8',
			'msg' => 'required|min:1',
		];
	}
}