argument('key'); // Find attachment by key $attachment = File_Attachment_Model::where('key', $key)->first(); if (!$attachment) { $this->error("Error: File attachment not found with key: {$key}"); return 1; } // Load relationships explicitly $storage = null; if ($attachment->file_storage_id) { $storage = \App\Models\File_Storage_Model::find($attachment->file_storage_id); } $site = null; if ($attachment->site_id) { $site = \Rsx\Models\Site_Model::find($attachment->site_id); } // Display file information $this->info(''); $this->info('File Attachment Information'); $this->info('==========================='); $this->info(''); $this->info('Identification:'); $this->info(" Key: {$attachment->key}"); $this->info(" Filename: {$attachment->file_name}"); $this->info(" Extension: {$attachment->file_extension}"); $this->info(''); $this->info('File Properties:'); $this->info(" Type: {$attachment->file_type_id_label}"); if ($storage) { $this->info(" Size: {$storage->get_human_size()}"); $this->info(' MIME: ' . mime_content_type($storage->get_full_path())); } $this->info(''); if ($storage) { $this->info('Storage:'); $this->info(" Hash: {$storage->hash}"); $this->info(" Path: {$storage->get_storage_path()}"); $this->info(' File Exists: ' . ($storage->file_exists() ? 'Yes' : 'No')); // Count references $ref_count = File_Attachment_Model::where('file_storage_id', $storage->id)->count(); $this->info(" References: {$ref_count}"); $this->info(''); } if ($attachment->fileable_type) { $this->info('Attached To:'); $this->info(" Model: {$attachment->fileable_type}"); $this->info(" Model ID: {$attachment->fileable_id}"); $this->info(''); } if ($attachment->fileable_category || $attachment->fileable_type_meta || $attachment->fileable_meta) { $this->info('Metadata:'); if ($attachment->fileable_category) { $this->info(" Category: {$attachment->fileable_category}"); } if ($attachment->fileable_type_meta) { $this->info(" Type Meta: {$attachment->fileable_type_meta}"); } if ($attachment->fileable_order !== null) { $this->info(" Order: {$attachment->fileable_order}"); } if ($attachment->fileable_meta) { $meta = $attachment->get_meta(); $this->info(' Meta JSON: ' . json_encode($meta, JSON_PRETTY_PRINT)); } $this->info(''); } $this->info('Site:'); $this->info(" Site ID: {$attachment->site_id}"); if ($site) { $this->info(" Site Name: {$site->name}"); } $this->info(''); $this->info('Timestamps:'); $this->info(" Created: {$attachment->created_at}"); $this->info(" Updated: {$attachment->updated_at}"); if ($attachment->created_by) { $this->info(" Created By: User #{$attachment->created_by}"); } if ($attachment->updated_by) { $this->info(" Updated By: User #{$attachment->updated_by}"); } $this->info(''); $this->info('URLs:'); $this->info(" View: {$attachment->get_url()}"); $this->info(" Download: {$attachment->get_download_url()}"); $this->info(''); return 0; } }