1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace App\Http\Requests\API\File;
- use App\Models\Enums\FileObjectType;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Validation\Rules\Enum;
- use Illuminate\Validation\Rules\File;
- class KeepDirectoryUploadRequest extends FormRequest
- {
- /**
- * Determine if the user is authorized to make this request.
- */
- public function authorize(): bool
- {
- return true;
- }
- /**
- * Get the validation rules that apply to the request.
- *
- * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
- */
- public function rules(): array
- {
- $rules = [
- "files" => "required|array",
- "folders" => "required|array",
- "object_type" => [
- "required",
- new Enum(FileObjectType::class),
- ],
- "object_id" => "min:0",
- "names" => "array",
- "folder_id" => "min:0",
- "uuid" => "max:40"
- ];
- if (! $this->request->has("object_id")) {
- $rules['uuid'] = "required|max:40";
- }
- $extensions = ['txt', 'jpeg', 'png', 'gif', 'pdf', 'xls', 'xlsx', 'zip', 'wps', 'docx', 'doc'];
- if ($this->request->get("object_type") == FileObjectType::CONTAINER->value) {
- $extensions = [...$extensions, ...config("bim.extensions")];
- }
- //$rules['files.*'][] = File::types($extensions)->max("2gb"); // 临时关闭,无法校验rvt文件后缀
- return $rules;
- }
- }
|