|string> */ public function rules(): array { $rules = [ "files.*" => [ 'required', ], "object_type" => [ 'required', new Enum(FileObjectType::class), ], "object_id" => [ function ($attribute, $value, $fail) { $exist = FileObjectType::from($this->get("object_type")) ->modelBuilderAllowed($value,($this->get("is_action")==='0')?true : ($this->get("is_action") === '1' ? false : false)) ->where("company_id", Auth::user()->company_id) ->where('id', $value) ->count(); if (! $exist) { $fail('Resources without permission to access.'); } } ], "source" => "in:1,2", ]; $rules['file.*'][] = $this->get("source", 1) == 1 ? File::types(['jpeg', 'png', 'gif'])->max("10mb") : File::types(['txt', 'jpeg', 'png', 'gif', 'pdf', 'xls', 'xlsx', 'zip', 'wps', 'docx', 'doc'])->max("2gb"); return $rules; } }