Updated import validation functionality
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Company;
|
||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Str;
|
||||
|
||||
class CompanyImporter extends Importer
|
||||
{
|
||||
@@ -25,6 +27,9 @@ class CompanyImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Company
|
||||
{
|
||||
if (Str::length($this->data['name']) < 0) {
|
||||
throw new RowImportFailedException("Company name not found");
|
||||
}
|
||||
return Company::updateOrCreate([
|
||||
'name' => $this->data['name']
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user