<?php


namespace App\Http\Requests\Demand\Process;

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

class DemandProcessRequest extends FormRequest
{
    use RequestApiFormValidation;

    private $storeApiRules = [
        'demand_id' => 'required',
        'explain' => 'required'
    ];

    private $storeApiMessage = [
        'demand_id.required' => '问题未指定',
        'explain.required' => '说明不能为空'
    ];

    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        $routeName = Route::currentRouteName();
        switch ($routeName) {
            case 'demand.process.storeApi':
                return $this->storeApiRules;
            default :
                return [];
        }
    }

    public function messages(): array
    {
        $routeName = Route::getCurrentRoute();
        switch ($routeName) {
            case 'demand.process.storeApi':
                return $this->storeApiMessage;
            default :
                return [];
        }
    }
}
