'integer', 'file_size' => 'integer', ]; } public function document(): BelongsTo { return $this->belongsTo(DocumentationDocument::class, 'document_id'); } public function file(): BelongsTo { return $this->belongsTo(File::class); } public function creator(): BelongsTo { return $this->belongsTo(User::class, 'created_by'); } public function isImage(): bool { return str_starts_with(strtolower((string) $this->file?->mime_type), 'image/'); } public function iconClass(): string { $mimeType = strtolower((string) $this->file?->mime_type); return match (true) { str_starts_with($mimeType, 'image/') => 'bi bi-file-earmark-image', $mimeType === 'application/pdf' => 'bi bi-file-earmark-pdf', $mimeType === 'application/msword', str_contains($mimeType, 'wordprocessingml') => 'bi bi-file-earmark-word', $mimeType === 'application/vnd.ms-excel', str_contains($mimeType, 'spreadsheetml') => 'bi bi-file-earmark-excel', $mimeType === 'application/vnd.ms-powerpoint', str_contains($mimeType, 'presentationml') => 'bi bi-file-earmark-ppt', str_starts_with($mimeType, 'audio/') => 'bi bi-file-earmark-music', str_starts_with($mimeType, 'video/') => 'bi bi-file-earmark-play', str_starts_with($mimeType, 'text/'), str_contains($mimeType, 'json'), str_contains($mimeType, 'xml') => 'bi bi-file-earmark-code', str_contains($mimeType, 'zip'), str_contains($mimeType, 'rar'), str_contains($mimeType, '7z'), str_contains($mimeType, 'gzip') => 'bi bi-file-earmark-zip', default => 'bi bi-file-earmark', }; } }