2024-08-07 18:29:23 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Imports;
|
|
|
|
|
|
|
|
|
|
use App\Imports\Sheets\PortfoliosSheet;
|
2024-09-18 19:50:31 -05:00
|
|
|
use Illuminate\Support\Facades\Artisan;
|
2024-08-29 22:26:04 -05:00
|
|
|
use App\Imports\Sheets\DailyChangesSheet;
|
2024-08-07 18:29:23 -05:00
|
|
|
use App\Imports\Sheets\TransactionsSheet;
|
2024-09-18 19:50:31 -05:00
|
|
|
use Maatwebsite\Excel\Events\AfterImport;
|
2024-08-07 18:29:23 -05:00
|
|
|
use Maatwebsite\Excel\Concerns\Importable;
|
2024-08-29 22:26:04 -05:00
|
|
|
use Maatwebsite\Excel\Concerns\WithEvents;
|
2024-09-18 20:14:30 -05:00
|
|
|
use App\Console\Commands\RefreshMarketData;
|
|
|
|
|
use App\Console\Commands\RefreshDividendData;
|
2024-08-07 18:29:23 -05:00
|
|
|
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
|
|
|
|
|
2024-08-29 22:26:04 -05:00
|
|
|
class BackupImport implements WithMultipleSheets, WithEvents
|
2024-08-07 18:29:23 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
use Importable;
|
|
|
|
|
|
2024-08-29 22:26:04 -05:00
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function registerEvents(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2024-09-18 21:09:50 -05:00
|
|
|
AfterImport::class =>
|
2024-09-18 23:03:23 -05:00
|
|
|
fn() => Artisan::queue(RefreshMarketData::class, ['--force' => true])->chain([
|
2024-09-18 21:09:50 -05:00
|
|
|
fn() => Artisan::call(RefreshDividendData::class)
|
|
|
|
|
])
|
2024-08-29 22:26:04 -05:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-07 18:29:23 -05:00
|
|
|
public function sheets(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'Portfolios' => new PortfoliosSheet,
|
2024-08-28 22:06:47 -05:00
|
|
|
'Transactions' => new TransactionsSheet,
|
2024-08-29 21:39:59 -05:00
|
|
|
'Daily Changes' => new DailyChangesSheet,
|
2024-08-07 18:29:23 -05:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|