Files
rspade_system/app/RSpade/Commands/Rsx/RsxFileInfoCommand.php
root 77b4d10af8 Refactor filename naming system and apply convention-based renames
Standardize settings file naming and relocate documentation files
Fix code quality violations from rsx:check
Reorganize user_management directory into logical subdirectories
Move Quill Bundle to core and align with Tom Select pattern
Simplify Site Settings page to focus on core site information
Complete Phase 5: Multi-tenant authentication with login flow and site selection
Add route query parameter rule and synchronize filename validation logic
Fix critical bug in UpdateNpmCommand causing missing JavaScript stubs
Implement filename convention rule and resolve VS Code auto-rename conflict
Implement js-sanitizer RPC server to eliminate 900+ Node.js process spawns
Implement RPC server architecture for JavaScript parsing
WIP: Add RPC server infrastructure for JS parsing (partial implementation)
Update jqhtml terminology from destroy to stop, fix datagrid DOM preservation
Add JQHTML-CLASS-01 rule and fix redundant class names
Improve code quality rules and resolve violations
Remove legacy fatal error format in favor of unified 'fatal' error type
Filter internal keys from window.rsxapp output
Update button styling and comprehensive form/modal documentation
Add conditional fly-in animation for modals
Fix non-deterministic bundle compilation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 19:10:02 +00:00

161 lines
5.0 KiB
PHP
Executable File

<?php
/**
* CODING CONVENTION:
* This file follows the coding convention where variable_names and function_names
* use snake_case (underscore_wherever_possible).
*/
namespace App\RSpade\Commands\Rsx;
use Illuminate\Console\Command;
use Rsx\Models\File_Attachment_Model;
/**
* File Info Command
* ==================
*
* PURPOSE:
* Display detailed information about a file attachment by its key.
*
* DISPLAYS:
* - File identification (key, name, extension)
* - File type and size
* - Storage information (hash, path)
* - Attachment metadata (category, type_meta, meta JSON)
* - Polymorphic relationship (if attached to model)
* - Site and user information
* - Timestamps
*/
class RsxFileInfoCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'rsx:file:info {key : 64-char hex attachment key}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Display detailed information about a file attachment';
/**
* Execute the console command.
*/
public function handle()
{
$key = $this->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;
}
}