<?php

namespace Modules\User\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class ImportUserRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => 'required|min:3|max:30|regex:/^\S*$/|unique:' . config('core.acl.users_table') . ',username,NULL,id,deleted_at,NULL',
            'firstname' => 'required|max:20',
            'lastname' => 'required|max:20',
            'email' => 'required|email|unique:' . config('core.acl.users_table') . ',email,NULL,id,deleted_at,NULL',
            'department' => 'required|exists:' . config('core.acl.departments_table') . ',name',
            'role' => 'required|exists:' . config('core.acl.roles_table') . ',name',
            'emp_id' => 'required|unique:' . config('core.acl.users_table') . ',emp_id,NULL,id,deleted_at,NULL',
        ];
    }

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