Merge pull request 'Added 'created_by', 'updated_by' columns StickerMaster screens' (#317) from ranjith-dev into master
Some checks are pending
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Waiting to run
Some checks are pending
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Waiting to run
Reviewed-on: #317
This commit was merged in pull request #317.
This commit is contained in:
@@ -76,8 +76,12 @@ class StickerMasterExporter extends Exporter
|
||||
->label('MATERIAL TYPE'),
|
||||
ExportColumn::make('bundle_quantity')
|
||||
->label('BUNDLE QUANTITY'),
|
||||
ExportColumn::make('created_by')
|
||||
->label('CREATED BY'),
|
||||
ExportColumn::make('created_at')
|
||||
->label('CREATED AT'),
|
||||
ExportColumn::make('updated_by')
|
||||
->label('UPDATED BY'),
|
||||
ExportColumn::make('updated_at')
|
||||
->label('UPDATED AT'),
|
||||
ExportColumn::make('deleted_at')
|
||||
|
||||
@@ -9,6 +9,7 @@ use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Filament\Facades\Filament;
|
||||
use Str;
|
||||
|
||||
class StickerMasterImporter extends Importer
|
||||
@@ -163,8 +164,13 @@ class StickerMasterImporter extends Importer
|
||||
{
|
||||
$warnMsg = [];
|
||||
$plantCod = $this->data['plant'];
|
||||
$itemCod = $this->data['item'];
|
||||
$plant = null;
|
||||
$item = null;
|
||||
$plantId = null;
|
||||
$itemId = null;
|
||||
$createdBy = Filament::auth()->user()->name;
|
||||
$updatedBy = 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 {
|
||||
@@ -174,60 +180,80 @@ class StickerMasterImporter extends Importer
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
} else {
|
||||
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item code not found';
|
||||
$plantId = $plant->id;
|
||||
if (Str::length($itemCod) < 6 || ! ctype_alnum($itemCod)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
} else {
|
||||
if (Str::length($this->data['serial_number_motor']) > 0 && $this->data['serial_number_motor'] != '1') {
|
||||
$warnMsg[] = 'Serial number motor must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pump']) > 0 && $this->data['serial_number_pump'] != '1') {
|
||||
$warnMsg[] = 'Serial number pump must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pumpset']) > 0 && $this->data['serial_number_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Serial number pumpset must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_motor']) > 0 && $this->data['pack_slip_motor'] != '1') {
|
||||
$warnMsg[] = 'Pack slip motor must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pump']) > 0 && $this->data['pack_slip_pump'] != '1') {
|
||||
$warnMsg[] = 'Pack slip pump must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pumpset']) > 0 && $this->data['pack_slip_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Pack slip pumpset must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['name_plate_motor']) > 0 && $this->data['name_plate_motor'] != '1') {
|
||||
$warnMsg[] = 'Name plate motor must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pump']) > 0 && $this->data['name_plate_pump'] != '1') {
|
||||
$warnMsg[] = 'Name plate pump must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pumpset']) > 0 && $this->data['name_plate_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Name plate pumpset must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_motor']) > 0 && $this->data['tube_sticker_motor'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker motor must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pump']) > 0 && $this->data['tube_sticker_pump'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker pump must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pumpset']) > 0 && $this->data['tube_sticker_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker pumpset must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['warranty_card']) > 0 && $this->data['warranty_card'] != '1') {
|
||||
$warnMsg[] = 'Warranty card must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['panel_box_code']) > 0 && (Str::length($this->data['panel_box_code']) < 6 || ! ctype_alnum($this->data['panel_box_code']))) {
|
||||
$warnMsg[] = 'Invalid panel box code found';
|
||||
}
|
||||
if (Str::length($this->data['load_rate']) < 0 || ! is_numeric($this->data['load_rate']) || $this->data['load_rate'] < 0) {
|
||||
$warnMsg[] = 'Load rate must be greater than or equal to 0';
|
||||
}
|
||||
if (Str::length($this->data['bundle_quantity']) > 0 && (! is_numeric($this->data['bundle_quantity']) || $this->data['bundle_quantity'] <= 1)) {
|
||||
$warnMsg[] = "Bundle quantity must be greater than or equal to '2' or empty";
|
||||
}
|
||||
if (Str::length($this->data['material_type']) > 0 && $this->data['material_type'] != '1' && $this->data['material_type'] != '2' && $this->data['material_type'] != '3') { // ($this->data['material_type'] != null) &&
|
||||
$warnMsg[] = 'Material type must be 1 or 2 or 3 or empty';
|
||||
$item = Item::where('code', $itemCod)->first();
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item code not found';
|
||||
} else {
|
||||
$item = Item::where('code', $itemCod)->where('plant_id', $plantId)->first();
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item code not found for the plant';
|
||||
} else {
|
||||
$itemId = $item->id;
|
||||
|
||||
if (Str::length($this->data['serial_number_motor']) > 0 && $this->data['serial_number_motor'] != '1') {
|
||||
$warnMsg[] = 'Serial number motor must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pump']) > 0 && $this->data['serial_number_pump'] != '1') {
|
||||
$warnMsg[] = 'Serial number pump must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pumpset']) > 0 && $this->data['serial_number_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Serial number pumpset must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_motor']) > 0 && $this->data['pack_slip_motor'] != '1') {
|
||||
$warnMsg[] = 'Pack slip motor must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pump']) > 0 && $this->data['pack_slip_pump'] != '1') {
|
||||
$warnMsg[] = 'Pack slip pump must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pumpset']) > 0 && $this->data['pack_slip_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Pack slip pumpset must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['name_plate_motor']) > 0 && $this->data['name_plate_motor'] != '1') {
|
||||
$warnMsg[] = 'Name plate motor must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pump']) > 0 && $this->data['name_plate_pump'] != '1') {
|
||||
$warnMsg[] = 'Name plate pump must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pumpset']) > 0 && $this->data['name_plate_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Name plate pumpset must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_motor']) > 0 && $this->data['tube_sticker_motor'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker motor must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pump']) > 0 && $this->data['tube_sticker_pump'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker pump must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pumpset']) > 0 && $this->data['tube_sticker_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker pumpset must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['warranty_card']) > 0 && $this->data['warranty_card'] != '1') {
|
||||
$warnMsg[] = 'Warranty card must be 1 or empty';
|
||||
}
|
||||
if (Str::length($this->data['panel_box_code']) > 0 && (Str::length($this->data['panel_box_code']) < 6 || ! ctype_alnum($this->data['panel_box_code']))) {
|
||||
$warnMsg[] = 'Invalid panel box code found';
|
||||
}
|
||||
if (Str::length($this->data['load_rate']) < 0 || ! is_numeric($this->data['load_rate']) || $this->data['load_rate'] < 0) {
|
||||
$warnMsg[] = 'Load rate must be greater than or equal to 0';
|
||||
}
|
||||
if (Str::length($this->data['bundle_quantity']) > 0 && (! is_numeric($this->data['bundle_quantity']) || $this->data['bundle_quantity'] <= 1)) {
|
||||
$warnMsg[] = "Bundle quantity must be greater than or equal to '2' or empty";
|
||||
}
|
||||
if (Str::length($this->data['material_type']) > 0 && $this->data['material_type'] != '1' && $this->data['material_type'] != '2' && $this->data['material_type'] != '3') { // ($this->data['material_type'] != null) &&
|
||||
$warnMsg[] = 'Material type must be 1 or 2 or 3 or empty';
|
||||
}
|
||||
|
||||
if (empty($warnMsg)) {
|
||||
$recExist = StickerMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first()?->created_by;
|
||||
|
||||
if ($recExist) {
|
||||
$createdBy = $recExist;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,8 +263,8 @@ class StickerMasterImporter extends Importer
|
||||
}
|
||||
|
||||
StickerMaster::updateOrCreate([
|
||||
'item_id' => $item->id,
|
||||
'plant_id' => $plant->id,
|
||||
'item_id' => $itemId,
|
||||
'plant_id' => $plantId,
|
||||
],
|
||||
[
|
||||
'serial_number_motor' => $this->data['serial_number_motor'],
|
||||
@@ -265,6 +291,8 @@ class StickerMasterImporter extends Importer
|
||||
'load_rate' => $this->data['load_rate'],
|
||||
'bundle_quantity' => $this->data['bundle_quantity'],
|
||||
'material_type' => $this->data['material_type'],
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]);
|
||||
|
||||
return null;
|
||||
|
||||
@@ -55,7 +55,7 @@ class StickerMasterResource extends Resource
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(StickerMaster::latest()->first())->plant_id;
|
||||
@@ -87,7 +87,8 @@ class StickerMasterResource extends Resource
|
||||
$set('tube_sticker_motor', false) &
|
||||
$set('tube_sticker_pump', false) &
|
||||
$set('tube_sticker_pumpset', false) &
|
||||
$set('warranty_card', false)
|
||||
$set('warranty_card', false) &
|
||||
$set('updated_by', Filament::auth()->user()?->name)
|
||||
)
|
||||
->required(),
|
||||
|
||||
@@ -128,6 +129,7 @@ class StickerMasterResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$itemId = $get('item_id');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
|
||||
// If plant_id is changed or empty, reset everything
|
||||
if (blank($plantId)) {
|
||||
@@ -207,36 +209,60 @@ class StickerMasterResource extends Resource
|
||||
|
||||
Forms\Components\TextInput::make('part_validation1')
|
||||
->label('Part Validation 1')
|
||||
->nullable(),
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation2')
|
||||
->label('Part Validation 2')
|
||||
->nullable(),
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation3')
|
||||
->label('Part Validation 3')
|
||||
->nullable(),
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation4')
|
||||
->label('Part Validation 4')
|
||||
->nullable(),
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('part_validation5')
|
||||
->label('Part Validation 5 (Capacitor QR)')
|
||||
->nullable(),
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('laser_part_validation1')
|
||||
->label('Laser Part Validation 1')
|
||||
->nullable(),
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('laser_part_validation2')
|
||||
->label('Laser Part Validation 2')
|
||||
->nullable(),
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('panel_box_code')
|
||||
->label('Panel Box Code')
|
||||
->readOnly(fn (callable $get) => $get('material_type'))
|
||||
->nullable(),
|
||||
->nullable()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\TextInput::make('load_rate')
|
||||
->label('Load Rate')
|
||||
@@ -245,7 +271,10 @@ class StickerMasterResource extends Resource
|
||||
->disabled(function ($get) {
|
||||
return $get('material_type');
|
||||
})
|
||||
->integer(),
|
||||
->integer()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\Select::make('material_type')
|
||||
->label('Material Type')
|
||||
@@ -256,7 +285,6 @@ class StickerMasterResource extends Resource
|
||||
])
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
|
||||
if ($state) {
|
||||
$set('panel_box_code', null);
|
||||
$set('load_rate', 0);
|
||||
@@ -267,7 +295,7 @@ class StickerMasterResource extends Resource
|
||||
} else {
|
||||
$set('bundle_quantity', 2);
|
||||
}
|
||||
// $plantId = $get('plant_id');
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->nullable(),
|
||||
|
||||
@@ -284,6 +312,7 @@ class StickerMasterResource extends Resource
|
||||
} elseif ($get('bundle_quantity') < 2) {
|
||||
$set('bundle_quantity', 2);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
|
||||
Forms\Components\Checkbox::make('serial_number_motor')
|
||||
@@ -295,6 +324,7 @@ class StickerMasterResource extends Resource
|
||||
if ($get('serial_number_motor')) {
|
||||
$set('serial_number_pumpset', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state): mixed => $state ? $state : null),
|
||||
|
||||
@@ -307,6 +337,7 @@ class StickerMasterResource extends Resource
|
||||
if ($get('serial_number_pump')) {
|
||||
$set('serial_number_pumpset', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
@@ -320,6 +351,7 @@ class StickerMasterResource extends Resource
|
||||
$set('serial_number_motor', false);
|
||||
$set('serial_number_pump', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
@@ -332,6 +364,7 @@ class StickerMasterResource extends Resource
|
||||
if ($get('pack_slip_motor')) {
|
||||
$set('pack_slip_pumpset', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
@@ -344,6 +377,7 @@ class StickerMasterResource extends Resource
|
||||
if ($get('pack_slip_pump')) {
|
||||
$set('pack_slip_pumpset', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
@@ -357,6 +391,7 @@ class StickerMasterResource extends Resource
|
||||
$set('pack_slip_motor', false);
|
||||
$set('pack_slip_pump', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
@@ -369,6 +404,7 @@ class StickerMasterResource extends Resource
|
||||
if ($get('name_plate_motor')) {
|
||||
$set('name_plate_pumpset', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
@@ -381,6 +417,7 @@ class StickerMasterResource extends Resource
|
||||
if ($get('name_plate_pump')) {
|
||||
$set('name_plate_pumpset', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
@@ -394,6 +431,7 @@ class StickerMasterResource extends Resource
|
||||
$set('name_plate_motor', false);
|
||||
$set('name_plate_pump', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
@@ -406,6 +444,7 @@ class StickerMasterResource extends Resource
|
||||
if ($get('tube_sticker_motor')) {
|
||||
$set('tube_sticker_pumpset', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
@@ -418,6 +457,7 @@ class StickerMasterResource extends Resource
|
||||
if ($get('tube_sticker_pump')) {
|
||||
$set('tube_sticker_pumpset', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
@@ -432,13 +472,24 @@ class StickerMasterResource extends Resource
|
||||
$set('tube_sticker_motor', false);
|
||||
$set('tube_sticker_pump', false);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null), // to pass null value
|
||||
|
||||
Forms\Components\Checkbox::make('warranty_card')
|
||||
->nullable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
@@ -465,8 +516,7 @@ class StickerMasterResource extends Resource
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->label('Plant')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('item.code')
|
||||
->label('Item Code')
|
||||
->alignCenter()
|
||||
@@ -593,17 +643,24 @@ class StickerMasterResource extends Resource
|
||||
default => '-',
|
||||
};
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->label('Deleted At')
|
||||
->dateTime()
|
||||
@@ -623,8 +680,9 @@ class StickerMasterResource extends Resource
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->orderBy('code')->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||
$set('item_id', null);
|
||||
@@ -658,16 +716,21 @@ class StickerMasterResource extends Resource
|
||||
->reactive(),
|
||||
Select::make('material_type')
|
||||
->label('Select Material Type')
|
||||
->nullable()
|
||||
->options([
|
||||
1 => 'Individual',
|
||||
2 => 'Bundle',
|
||||
3 => 'Quantity',
|
||||
])
|
||||
->searchable()
|
||||
->reactive(),
|
||||
|
||||
TextInput::make('panel_box_code')
|
||||
->label('Search by Panel Box Code')
|
||||
->placeholder(placeholder: 'Enter Panel Box Code'),
|
||||
TextInput::make('created_by')
|
||||
->label('Created By')
|
||||
->placeholder(placeholder: 'Enter Created By Name'),
|
||||
DateTimePicker::make(name: 'created_from')
|
||||
->label('Created From')
|
||||
->placeholder(placeholder: 'Select From DateTime')
|
||||
@@ -678,10 +741,13 @@ class StickerMasterResource extends Resource
|
||||
->placeholder(placeholder: 'Select To DateTime')
|
||||
->reactive()
|
||||
->native(false),
|
||||
TextInput::make('updated_by')
|
||||
->label('Updated By')
|
||||
->placeholder(placeholder: 'Enter Updated By Name'),
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['item_id']) && empty($data['material_type']) && empty($data['panel_box_code']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
if (empty($data['Plant']) && empty($data['item_id']) && empty($data['material_type']) && empty($data['panel_box_code']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['created_by']) && empty($data['updated_by'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -707,6 +773,10 @@ class StickerMasterResource extends Resource
|
||||
$query->where('panel_box_code', 'like', '%'.$data['panel_box_code'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['created_by'])) {
|
||||
$query->where('created_by', 'like', '%'.$data['created_by'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$query->where('created_at', '>=', $data['created_from']);
|
||||
}
|
||||
@@ -715,6 +785,9 @@ class StickerMasterResource extends Resource
|
||||
$query->where('created_at', '<=', $data['created_to']);
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$query->where('updated_by', 'like', '%'.$data['updated_by'].'%');
|
||||
}
|
||||
})
|
||||
->indicateUsing(function (array $data) {
|
||||
$indicators = [];
|
||||
@@ -748,6 +821,10 @@ class StickerMasterResource extends Resource
|
||||
$indicators[] = 'Panel Box Code: '.$data['panel_box_code'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_by'])) {
|
||||
$indicators[] = 'Created By: '.$data['created_by'];
|
||||
}
|
||||
|
||||
if (! empty($data['created_from'])) {
|
||||
$indicators[] = 'From: '.$data['created_from'];
|
||||
}
|
||||
@@ -756,6 +833,10 @@ class StickerMasterResource extends Resource
|
||||
$indicators[] = 'To: '.$data['created_to'];
|
||||
}
|
||||
|
||||
if (! empty($data['updated_by'])) {
|
||||
$indicators[] = 'Updated By: '.$data['updated_by'];
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
])
|
||||
@@ -779,7 +860,7 @@ class StickerMasterResource extends Resource
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->label('Select Plant')
|
||||
->required()
|
||||
|
||||
@@ -13,7 +13,7 @@ class StickerMaster extends Model
|
||||
protected $fillable = [
|
||||
'item_id',
|
||||
'plant_id',
|
||||
'panel_box_code',
|
||||
'panel_box_code',
|
||||
'serial_number_motor',
|
||||
'serial_number_pump',
|
||||
'serial_number_pumpset',
|
||||
@@ -34,9 +34,13 @@ class StickerMaster extends Model
|
||||
'part_validation5',
|
||||
'laser_part_validation1',
|
||||
'laser_part_validation2',
|
||||
'load_rate',
|
||||
'load_rate',
|
||||
'bundle_quantity',
|
||||
'material_type',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
public function item()
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE sticker_masters
|
||||
ADD COLUMN created_by TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
|
||||
$sql2 = <<<'SQL'
|
||||
ALTER TABLE sticker_masters
|
||||
ADD COLUMN updated_by TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql2);
|
||||
// Schema::table('sticker_masters', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('sticker_masters', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user