UserSaveShareRequest.php 852 Bytes
<?php

namespace App\Http\Container\AppSection\Requests;

use App\Models\UserShare;
use Hikoon\LaravelApi\Support\ApiRequest;

class UserSaveShareRequest extends ApiRequest
{
    /**
     * @return void
     */
    public function prepareForValidation(): void
    {
        $this->merge(['subject_type' => data_get(UserShare::TYPE, $this->input('subject_type'))]);
    }

    public function rules(): array
    {
        return [
            'to_id'        => 'required|numeric',
            'subject_type' => 'required',
            'subject_id'   => 'required'
        ];
    }

    public function messages(): array
    {
        return [
            'to_id.required'        => '请选择被分享人',
            'subject_type.required' => '请选择分享类型',
            'subject_id.required'   => '请选择分享数据'
        ];
    }
}