Added update or create record on import
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\Block;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Notification;
|
||||
|
||||
class BlockImporter extends Importer
|
||||
{
|
||||
@@ -32,12 +33,18 @@ class BlockImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Block
|
||||
{
|
||||
$plant = \App\Models\Plant::where('name', $this->data['plant'])->first();
|
||||
return Block::updateOrCreate([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id
|
||||
]
|
||||
);
|
||||
// return Block::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Block();
|
||||
// return new Block();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
Reference in New Issue
Block a user