<?php

namespace App\Http\Requests\Employee;

use Illuminate\Foundation\Http\FormRequest;

class UpdateRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $id = $this->route('employee');

        return $rules = [
            'organization_id' => 'required|exists:organizations,id',
            'herd_id' => 'required|exists:herds,id',
            'lot_id' => 'required|exists:lots,id',
            'breed_id' => 'required|exists:breeds,id',
            'tag_id' => 'required|exists:tags,id|unique:employees,tag_id,' . $id,
            'sire_id' => 'required|exists:sires,id',
            'species' => 'required',
            'sex' => 'required',
            'birth_date' => 'required',
            'status' => 'required',
            'source' => 'required',
            'dam_source' => 'required',
            'mother_id' => 'required_if:dam_source,==,organizationbred',
            'dam' => 'required_if:dam_source,==,purchased',
            'employee_image.*' => 'image|file|max:10000',
        ];
    }
}
