<?php

namespace Mehrab\RolePermission\Http\Requests;

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

class role_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 = $this->role_permission;
        return [
            'name' => ['required','min:2',Rule::unique('roles','name')->ignore($id)],
            'permissions' => ['required','array']
        ];
    }
}
