Changed sticker detail importer logic #886
@@ -10,6 +10,7 @@ use Filament\Actions\Imports\ImportColumn;
|
|||||||
use Filament\Actions\Imports\Importer;
|
use Filament\Actions\Imports\Importer;
|
||||||
use Filament\Actions\Imports\Models\Import;
|
use Filament\Actions\Imports\Models\Import;
|
||||||
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
|
||||||
class StickerDetailImporter extends Importer
|
class StickerDetailImporter extends Importer
|
||||||
{
|
{
|
||||||
@@ -39,11 +40,11 @@ class StickerDetailImporter extends Importer
|
|||||||
->exampleHeader('Element Type')
|
->exampleHeader('Element Type')
|
||||||
->label('ELEMENT TYPE')
|
->label('ELEMENT TYPE')
|
||||||
->example('Static/Dynamic'),
|
->example('Static/Dynamic'),
|
||||||
// ImportColumn::make('characteristics_type')
|
ImportColumn::make('characteristics_type')
|
||||||
// ->requiredMapping()
|
->requiredMapping()
|
||||||
// ->exampleHeader('Characteristics Type')
|
->exampleHeader('Characteristics Type')
|
||||||
// ->label('CHARACTERISTICS TYPE')
|
->label('CHARACTERISTICS TYPE')
|
||||||
// ->example('ZMM values'),
|
->example('zmm_heading'),
|
||||||
ImportColumn::make('string_value')
|
ImportColumn::make('string_value')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('String Value')
|
->exampleHeader('String Value')
|
||||||
@@ -89,11 +90,11 @@ class StickerDetailImporter extends Importer
|
|||||||
->exampleHeader('Shape Pen Size')
|
->exampleHeader('Shape Pen Size')
|
||||||
->label('SHAPE PEN SIZE')
|
->label('SHAPE PEN SIZE')
|
||||||
->example('0.3'),
|
->example('0.3'),
|
||||||
// ImportColumn::make('curve_radius')
|
ImportColumn::make('curve_radius')
|
||||||
// ->requiredMapping()
|
->requiredMapping()
|
||||||
// ->exampleHeader('Curve Radius')
|
->exampleHeader('Curve Radius')
|
||||||
// ->label('CURVE RADIUS')
|
->label('CURVE RADIUS')
|
||||||
// ->example('3'),
|
->example('3'),
|
||||||
ImportColumn::make('shape_x1_value')
|
ImportColumn::make('shape_x1_value')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Shape X1 Value')
|
->exampleHeader('Shape X1 Value')
|
||||||
@@ -159,11 +160,11 @@ class StickerDetailImporter extends Importer
|
|||||||
->exampleHeader('QR Y Value')
|
->exampleHeader('QR Y Value')
|
||||||
->label('QR Y VALUE')
|
->label('QR Y VALUE')
|
||||||
->example('40'),
|
->example('40'),
|
||||||
ImportColumn::make('created_by')
|
// ImportColumn::make('created_by')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Created By')
|
// ->exampleHeader('Created By')
|
||||||
->label('CREATED BY')
|
// ->label('CREATED BY')
|
||||||
->example('RAW001234'),
|
// ->example('RAW001234'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,25 +172,22 @@ class StickerDetailImporter extends Importer
|
|||||||
{
|
{
|
||||||
|
|
||||||
$warnMsg = [];
|
$warnMsg = [];
|
||||||
|
$createdBy = Filament::auth()->user()->name;
|
||||||
|
$updatedBy = Filament::auth()->user()->name;
|
||||||
|
|
||||||
$sticker = $this->data['sticker_structure_detail_id'] ?? null;
|
$sticker = $this->data['sticker_structure_detail_id'] ?? null;
|
||||||
|
|
||||||
$stickerCode = StickerStructureDetail::where('sticker_id', $sticker)->first();
|
$stickerCode = StickerStructureDetail::where('sticker_id', $sticker)->first();
|
||||||
if (!$stickerCode) {
|
if (!$stickerCode) {
|
||||||
$warnMsg[] = "Sticker Id not found in Sticker Structure Detail";
|
$warnMsg[] = "Sticker Id not found in Sticker Structure Detail";
|
||||||
|
}else{
|
||||||
|
$stickerId = $stickerCode->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$stickerId = $stickerCode->id;
|
|
||||||
|
|
||||||
if (!$stickerId || $stickerId == null || $stickerId == '') {
|
if (!$stickerId || $stickerId == null || $stickerId == '') {
|
||||||
$warnMsg[] = "Sticker Id not found in Sticker Structure Detail";
|
$warnMsg[] = "Sticker Id not found in Sticker Structure Detail";
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::where('name', $this->data['created_by'])->first();
|
|
||||||
if (!$user) {
|
|
||||||
$warnMsg[] = "User not found";
|
|
||||||
}
|
|
||||||
|
|
||||||
$designType = strtolower($this->data['design_element_type'] ?? '');
|
$designType = strtolower($this->data['design_element_type'] ?? '');
|
||||||
|
|
||||||
$rules = [
|
$rules = [
|
||||||
@@ -281,7 +279,7 @@ class StickerDetailImporter extends Importer
|
|||||||
'design_element_type' => $this->data['design_element_type'],
|
'design_element_type' => $this->data['design_element_type'],
|
||||||
'element_id' => $this->data['element_id'],
|
'element_id' => $this->data['element_id'],
|
||||||
'element_type' => $this->data['element_type'],
|
'element_type' => $this->data['element_type'],
|
||||||
// 'characteristics_type' => $this->data['characteristics_type'],
|
'characteristics_type' => $this->data['characteristics_type'],
|
||||||
'string_value' => $this->data['string_value'],
|
'string_value' => $this->data['string_value'],
|
||||||
'string_font' => $this->data['string_font'],
|
'string_font' => $this->data['string_font'],
|
||||||
'string_size' => $this->data['string_size'],
|
'string_size' => $this->data['string_size'],
|
||||||
@@ -291,7 +289,7 @@ class StickerDetailImporter extends Importer
|
|||||||
'string_y_value' => $this->data['string_y_value'],
|
'string_y_value' => $this->data['string_y_value'],
|
||||||
'shape_name' => $this->data['shape_name'],
|
'shape_name' => $this->data['shape_name'],
|
||||||
'shape_pen_size' => $this->data['shape_pen_size'],
|
'shape_pen_size' => $this->data['shape_pen_size'],
|
||||||
// 'curve_radius' => $this->data['curve_radius'],
|
'curve_radius' => $this->data['curve_radius'],
|
||||||
'shape_x1_value' => $this->data['shape_x1_value'],
|
'shape_x1_value' => $this->data['shape_x1_value'],
|
||||||
'shape_y1_value' => $this->data['shape_y1_value'],
|
'shape_y1_value' => $this->data['shape_y1_value'],
|
||||||
'shape_x2_value' => $this->data['shape_x2_value'],
|
'shape_x2_value' => $this->data['shape_x2_value'],
|
||||||
@@ -305,7 +303,8 @@ class StickerDetailImporter extends Importer
|
|||||||
'qr_size' => $this->data['qr_size'],
|
'qr_size' => $this->data['qr_size'],
|
||||||
'qr_x_value' => $this->data['qr_x_value'],
|
'qr_x_value' => $this->data['qr_x_value'],
|
||||||
'qr_y_value' => $this->data['qr_y_value'],
|
'qr_y_value' => $this->data['qr_y_value'],
|
||||||
'created_by' => $this->data['created_by'],
|
'created_by' => $createdBy,
|
||||||
|
'updated_by' => $updatedBy,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user