Refactor plant selection logic in ItemResource and StickerMasterResource to order by code #33
@@ -237,9 +237,6 @@ class ItemResource extends Resource
|
|||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
])
|
])
|
||||||
// ->filters([
|
|
||||||
// Tables\Filters\TrashedFilter::make(),
|
|
||||||
// ])
|
|
||||||
->filters([
|
->filters([
|
||||||
Tables\Filters\TrashedFilter::make(),
|
Tables\Filters\TrashedFilter::make(),
|
||||||
Filter::make('advanced_filters')
|
Filter::make('advanced_filters')
|
||||||
@@ -251,11 +248,11 @@ class ItemResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$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)->orderBy('code')->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
$set('item_id', null);
|
$set('code', null);
|
||||||
$set('operator_id', null);
|
$set('operator_id', null);
|
||||||
}),
|
}),
|
||||||
Select::make('code')
|
Select::make('code')
|
||||||
@@ -300,7 +297,7 @@ class ItemResource extends Resource
|
|||||||
// Hide all records initially if no filters are applied
|
// Hide all records initially if no filters are applied
|
||||||
if (
|
if (
|
||||||
empty($data['Plant']) &&
|
empty($data['Plant']) &&
|
||||||
empty($data['item_id']) &&
|
empty($data['code']) &&
|
||||||
empty($data['description']) &&
|
empty($data['description']) &&
|
||||||
empty($data['uom']) &&
|
empty($data['uom']) &&
|
||||||
empty($data['category']) &&
|
empty($data['category']) &&
|
||||||
@@ -314,8 +311,8 @@ class ItemResource extends Resource
|
|||||||
$query->where('plant_id', $data['Plant']);
|
$query->where('plant_id', $data['Plant']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['item_id'])) {
|
if (! empty($data['code'])) {
|
||||||
$query->where('item_id', $data['item_id']);
|
$query->where('id', $data['code']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['description'])) {
|
if (! empty($data['description'])) {
|
||||||
@@ -337,7 +334,6 @@ class ItemResource extends Resource
|
|||||||
if (! empty($data['created_to'])) {
|
if (! empty($data['created_to'])) {
|
||||||
$query->where('created_at', '<=', $data['created_to']);
|
$query->where('created_at', '<=', $data['created_to']);
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
->indicateUsing(function (array $data) {
|
->indicateUsing(function (array $data) {
|
||||||
$indicators = [];
|
$indicators = [];
|
||||||
@@ -346,8 +342,8 @@ class ItemResource extends Resource
|
|||||||
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['item_id'])) {
|
if (! empty($data['code'])) {
|
||||||
$indicators[] = 'Item Code: '.$data['item_id'];
|
$indicators[] = 'Item Code: '.Item::where('id', $data['code'])->value('code');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['description'])) {
|
if (! empty($data['description'])) {
|
||||||
@@ -621,10 +617,10 @@ class ItemResource extends Resource
|
|||||||
}),
|
}),
|
||||||
// ->maxRows(100000),
|
// ->maxRows(100000),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
// ->columnMapping(true)
|
// ->columnMapping(true)
|
||||||
->label('Export Items')
|
->label('Export Items')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
// ->fileName("Items Report " . date('Y-m-d H:i:s'))
|
// ->fileName("Items Report " . date('Y-m-d H:i:s'))
|
||||||
->exporter(ItemExporter::class)
|
->exporter(ItemExporter::class)
|
||||||
->visible(function () {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export item');
|
return Filament::auth()->user()->can('view export item');
|
||||||
|
|||||||
@@ -601,7 +601,7 @@ class StickerMasterResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$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)->orderBy('code')->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
->afterStateUpdated(function ($state, callable $set, callable $get): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user