Updated validation functionality on import
This commit is contained in:
@@ -52,16 +52,24 @@ class LocatorImporter extends Importer
|
||||
public function resolveRecord(): ?Locator
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
||||
$plantCod = $this->data['plant'];
|
||||
$plant = null;
|
||||
$user = null;
|
||||
$locator = $this->data['locator_number'];
|
||||
// $locatorQuantity = $this->data['locator_quantity'];
|
||||
$palletQuantity = 0;
|
||||
$user = Filament::auth()->user()->name;
|
||||
if (Str::length($plantCod) < 4 || !is_numeric($plantCod) || !preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||
$warnMsg[] = "Invalid plant code found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$plant = Plant::where('code', $plantCod)->first();
|
||||
if (!$plant) {
|
||||
$warnMsg[] = "Plant not found";
|
||||
}
|
||||
else
|
||||
{
|
||||
$user = Filament::auth()->user()->name;
|
||||
if (Str::length($locator) < 7) {
|
||||
$warnMsg[] = "Invalid locator number found";
|
||||
}
|
||||
@@ -70,6 +78,7 @@ class LocatorImporter extends Importer
|
||||
$palletQuantity = PalletValidation::where('locator_number', $locator)->where('plant_id', $plant->id)->distinct('pallet_number')->count('pallet_number');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (Str::length($locatorQuantity) < 0 || !is_numeric($locatorQuantity) || $locatorQuantity < 0 || $locatorQuantity > 2) {
|
||||
// $warnMsg[] = "Invalid locator quantity found";
|
||||
|
||||
Reference in New Issue
Block a user