ProjectUpdateRequest.php 1.75 KB
<?php

namespace App\Http\Container\AdminSection\Requests\Audition;

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

class ProjectUpdateRequest extends ApiRequest
{
    protected function prepareForValidation(): void
    {
        $this->merge(['master_id' => $this->integer('master_id')]);
    }

    public function rules(): array
    {
        return [
            'cover'             => 'bail|required|string|url',
            'name'              => 'bail|required|string|unique:' . Project::class . ',name,' . $this->route('project.id') . ',id,status,1,deleted_at,NULL',
            'intro'             => 'bail|nullable|sometimes',
            'is_promote'        => 'bail|required|in:0,1',
            'is_public'         => 'bail|required|in:0,1',
            'is_can_apply'      => 'required|in:0,1',
            'is_can_demo_apply' => 'required|in:0,1',
            'is_can_manage'     => 'required|in:0,1',
            'master_id'         => 'sometimes|numeric'
        ];
    }

    public function messages(): array
    {
        return [
            'cover.required'    => "请上传厂牌图片",
            'cover.url'         => "厂牌图片格式错误",
            'name.required'     => '请输入厂牌名称',
            'name.unique'       => '厂牌名称已存在',
            'is_promote.*'      => '请选择是否确认分享人',
            'is_public.*'       => '请选择是否仅显示自己创建的试唱歌曲',
            'is_can_apply.*'    => '请选择是否允许提交歌曲上架',
            'is_can_demo_apply' => '请选择是否允许提交Demo上架',
            'is_can_manage.*'   => '请选择是否允许自行添加外部成员',
            'master_id.numeric' => '主理人类型错误'
        ];
    }
}