<?php

namespace App\Http\Requests\Api\ShiftAssignment;

use Illuminate\Foundation\Http\FormRequest;

class UserShiftAssignmentRequest 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()
    {
        $rules = [
            'user_ids' => 'required',
            'shift_id' => 'required',
        ];

        if ($this->assign_shifts_by == 'month') {
            $rules['shift_assignment_month'] = 'required';
        } else {
            $rules['date'] = 'required';
        }

        return $rules;
    }
}
