ifnex/04_Laravel/app/Console/Commands/ImportHistoricalData.php
Kazem Alghasi a59e192b32 ۱۰ مورد کامل شد (دیتابیس، مدل‌ها، API، Filament، Laravel 11، رفع باگ‌ها)
🔄 در حال انجام: تست دستی Filament
⏸️ بلاک: مهاجرت ۳۹۵۰ رکورد (منتظر فایل اکسل اصلاح‌شده)
⏸️ بلاک: پلاگین وردپرس (بعد از تست کامل API)
2026-08-04 01:59:08 +03:30

33 lines
855 B
PHP

<?php
namespace App\Console\Commands;
use App\Imports\HistoricalShipmentsImport;
use Illuminate\Console\Command;
use Maatwebsite\Excel\Facades\Excel;
class ImportHistoricalData extends Command
{
protected $signature = 'ifnex:import:shipments {path : Path to the Excel file} {--sh|skip-header : Skip first row if it is a header}';
protected $description = 'Import historical shipments from Excel into the shipments table';
public function handle(): int
{
$path = $this->argument('path');
if (!file_exists($path)) {
$this->error("File not found: $path");
return 1;
}
$this->info('Starting historical shipments import...');
Excel::import(new HistoricalShipmentsImport(), $path);
$this->info('Historical shipments import completed.');
return 0;
}
}