mock up import export

This commit is contained in:
hackerESQ
2024-08-07 18:29:23 -05:00
parent b090908d09
commit 991d484152
19 changed files with 1085 additions and 2 deletions
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace App\Imports\Sheets;
use App\Models\Dividend;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
class DividendsSheet implements ToCollection, WithHeadingRow, SkipsEmptyRows
{
// use Importable;
public function collection(Collection $dividend)
{
foreach ($dividend->sortBy('date') as $row) {
Dividend::updateOrCreate([
'symbol' => $row['symbol'],
'date' => $row['date'],
],[
'symbol' => $row['symbol'],
'dividend_amount' => $row['amount'] ?? 0,
'date' => $row['date'],
]);
}
}
}