DynamicQueryRequest.php 926 Bytes
<?php

namespace App\Http\Container\AppSection\Requests;

use Hikoon\LaravelApi\Support\ApiRequest;

class DynamicQueryRequest extends ApiRequest
{

    protected function prepareForValidation(): void
    {
        $this->mergeIfMissing([
            'pageSize' => 20
        ]);
    }

    /**
     * @return string[]
     */
    public function rules(): array
    {
        return [
            'user_id'  => 'required|integer',
            'type'     => 'required|in:image,video,audio',
            'pageSize' => 'required|integer|max:100'
        ];
    }

    /**
     * @return string[]
     */
    public function messages(): array
    {
        return [
            'user_id.required' => '请选择查看用户',
            'type.required'    => '请选择查看方式',
            'type.in'          => '查看方式不存在',
            'pageSize'         => '每页显示数不能超过:max'
        ];
    }
}