- Complete product and inventory management system - Media storage service with proper path conventions - Image handling with dynamic resizing - Database migrations for inventory tracking - Import tools for legacy data migration - Documentation improvements - InventoryItem, InventoryMovement, InventoryAlert models with hashid support - Purchase order tracking on inventory alerts - Inventory dashboard for sellers - Stock level monitoring and notifications - MediaStorageService enforcing consistent path conventions - Image controller with dynamic resizing capabilities - Migration tools for moving images to MinIO - Proper slug-based paths (not IDs or hashids) - ImportProductsFromRemote command - ImportAlohaSales, ImportThunderBudBulk commands - ExploreRemoteDatabase for schema inspection - Legacy data migration utilities - Product variations table - Remote customer mappings - Performance indexes for stats queries - Social media fields for brands - Module flags for businesses - New migrations for inventory, hashids, performance indexes - New services: MediaStorageService - New middleware: EnsureBusinessHasModule, EnsureUserHasCapability - Import commands for legacy data - Inventory models and controllers - Updated views for marketplace and seller areas - Documentation reorganization (archived old docs) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\InventoryItem;
|
|
use Illuminate\Console\Command;
|
|
|
|
class GenerateInventoryItemHashids extends Command
|
|
{
|
|
protected $signature = 'inventory:generate-hashids';
|
|
|
|
protected $description = 'Generate hashids for inventory items, movements, and alerts that don\'t have them';
|
|
|
|
public function handle(): int
|
|
{
|
|
// Process InventoryItems
|
|
$this->processModel(InventoryItem::class, 'inventory items');
|
|
|
|
// Process InventoryMovements
|
|
$this->processModel(\App\Models\InventoryMovement::class, 'inventory movements');
|
|
|
|
// Process InventoryAlerts
|
|
$this->processModel(\App\Models\InventoryAlert::class, 'inventory alerts');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
protected function processModel(string $modelClass, string $label): void
|
|
{
|
|
$records = $modelClass::whereNull('hashid')->get();
|
|
|
|
if ($records->isEmpty()) {
|
|
$this->info("✓ All {$label} already have hashids!");
|
|
|
|
return;
|
|
}
|
|
|
|
$this->info("Found {$records->count()} {$label} without hashids. Generating...");
|
|
|
|
$bar = $this->output->createProgressBar($records->count());
|
|
$bar->start();
|
|
|
|
foreach ($records as $record) {
|
|
$record->hashid = $record->generateHashid();
|
|
$record->saveQuietly(); // Don't trigger observers/events
|
|
$bar->advance();
|
|
}
|
|
|
|
$bar->finish();
|
|
$this->newLine();
|
|
$this->info("✅ Generated hashids for {$records->count()} {$label}!");
|
|
$this->newLine();
|
|
}
|
|
}
|