KeepDirectoryUploadRequest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Http\Requests\API\File;
  3. use App\Models\Enums\FileObjectType;
  4. use Illuminate\Foundation\Http\FormRequest;
  5. use Illuminate\Validation\Rules\Enum;
  6. use Illuminate\Validation\Rules\File;
  7. class KeepDirectoryUploadRequest extends FormRequest
  8. {
  9. /**
  10. * Determine if the user is authorized to make this request.
  11. */
  12. public function authorize(): bool
  13. {
  14. return true;
  15. }
  16. /**
  17. * Get the validation rules that apply to the request.
  18. *
  19. * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
  20. */
  21. public function rules(): array
  22. {
  23. $rules = [
  24. "files" => "required|array",
  25. "folders" => "required|array",
  26. "object_type" => [
  27. "required",
  28. new Enum(FileObjectType::class),
  29. ],
  30. "object_id" => "required|min:0",
  31. "names" => "array",
  32. "folder_id" => "min:0"
  33. ];
  34. $rules['files.*'][] = File::types(['txt', 'jpeg', 'png', 'gif', 'pdf', 'xls', 'xlsx', 'zip', 'wps', 'docx', 'doc'])->max("2gb");
  35. return $rules;
  36. }
  37. }