<?php

namespace App\Http\Requests\Station;

use App\Traits\RequestApiFormValidation;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Route;

class StationRuleBatchRequest extends FormRequest
{
    use RequestApiFormValidation;

    protected $storeApiRules = [
        'name' => 'required',
        'owner_id' => 'required'
    ];
    protected $updateApiRules = [
        'name' => 'required',
        'owner_id' => 'required'
    ];
    protected $storeApiMessage = [
        'name.required' => '规则名称为必填项',
        'owner_id.required' => '货主为必填项',
    ];
    protected $updateApiMessage = [
        'name.required' => '规则名称为必填项',
        'owner_id.required' => '货主为必填项',
    ];

    /**
     * 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(): array
    {
        $routeName = Route::currentRouteName();
        switch ($routeName) {
            case 'station.rule.storeApi':
                return $this->storeApiRules;
            case 'station.rule.updateApi':
                return $this->updateApiRules;
            default:
                return [];
        }
    }

    public function messages(): array
    {
        $routeName = Route::currentRouteName();
        switch ($routeName) {
            case 'station.rule.storeApi':
                return $this->storeApiMessage;
            case 'station.rule.updateApi':
                return $this->updateApiMessage;
            default:
                return [];
        }
    }
}
