<?php

namespace Mehrab\Region\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Mehrab\City\Repositories\CityRepo;
use Mehrab\RolePermission\Repositories\RoleRepo;
use Spatie\Permission\Models\Role;

class region_update_request 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()
    {
        $id = intval(request()->region);
        return [
            'name' => ['required','string','min:2'],
            'slug' => ['required','string','min:2',Rule::unique('regions','slug')->ignore($id)],
            'priority' =>['numeric'],
            'city' =>['exists:cities,id','required','numeric']
        ];
    }
}
