ProjectCreateRequest.php 1.86 KB
<?php

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

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

class ProjectCreateRequest extends ApiRequest
{
    /**
     * @return void
     */
    public function prepareForValidation(): void
    {
        $this->merge(['is_demo_audit' => 0]);
    }

    /**
     * @return string[]
     */
    public function rules(): array
    {
        return [
            'cover'             => 'required|string|url',
            'name'              => 'required|string|unique:' . Project::class . ',name,NULL,id,status,1,deleted_at,NULL',
            'intro'             => 'nullable|sometimes',
            'is_public'         => 'required|in:0,1',
            'is_can_apply'      => 'required|in:0,1',
            'is_can_manage'     => 'required|in:0,1',
            'is_can_demo_apply' => 'required|in:0,1',
            'is_demo_audit'     => 'required|in:0,1',
            'master_id'         => 'sometimes|numeric'
        ];
    }

    /**
     * @return string[]
     */
    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' => '主理人类型错误',
            'is_demo_audit'     => '请选择Demo上架是否需要审核',
        ];
    }
}