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