*/ protected $casts = [ 'id' => 'integer', 'file_path' => 'string', 'file_size' => 'string', 'file_content_type' => 'string', 'file_metadata' => 'json-array', 'type' => 'string', 'description' => 'string', 'language_code' => '?string', 'uploaded_by' => 'integer', 'updated_by' => 'integer', ]; public function setFilePath(string $path): self { $this->attributes['file_path'] = $path; [ 'filename' => $filename, 'dirname' => $dirname, 'extension' => $extension, ] = pathinfo($path); $this->file_name = $filename; $this->file_directory = $dirname; $this->file_extension = $extension; return $this; } public function saveInDisk(File $file, string $dirname, string $filename): void { helper('media'); $this->file_content_type = $file->getMimeType(); $filePath = save_media($file, $dirname, $filename); $this->file_path = $filePath; } public function injectFileData(File $file): void { $this->file_content_type = $file->getMimeType(); $this->type = 'document'; if ($filesize = filesize(media_path($this->file_path))) { $this->file_size = $filesize; } } }