<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class CustomerRequest 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 [
            'id_branch' => 'required',
            'nama' => 'required',
            'email' => 'required|unique:customer,email',
            'phone' => 'required|unique:customer,phone',
            'category_id' => 'required',            
        ];
    }

    public function messages()
    {
        return [
            'id_branch.required' => 'Gerai harus diisi.',
            'nama.required' => 'Nama harus diisi.',
            'email.required' => 'Email harus diisi.',
            'email.unique' => 'Email telah digunakan.',
            'phone.required' => 'No Telepon harus diisi.',
            'phone.unique' => 'No Telepon telah digunakan.',
            'category_id.required' => 'Kategori harus diisi'
        ];
    }
}
