Added category in production target page and added in livewire table
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 19s
Laravel Pint / pint (pull_request) Successful in 4m2s
Laravel Larastan / larastan (pull_request) Failing after 5m16s

This commit is contained in:
dhanabalan
2026-02-23 14:44:59 +05:30
parent b698493e1a
commit f818a8c44b
3 changed files with 205 additions and 51 deletions

View File

@@ -31,47 +31,6 @@ class ProductionTarget extends Page
->schema([
Section::make('')
->schema([
Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->reactive()
// ->searchable()
->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();
})
->required()
->afterStateUpdated(function ($state, callable $get, $set) {
// dd($state);
$set('line_id', null);
$set('year', null);
$set('month', null);
$this->dispatch('loadData',$state, '', '', '');
}),
Select::make('line_id')
->label('Line')
->required()
->relationship('line', 'name')
// ->searchable()
->columnSpan(1)
->options(function (callable $get) {
if (!$get('plant_id')) {
return [];
}
return \App\Models\Line::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $get, $set) {
$plantId = $get('plant_id');
$set('year', null);
$set('month', null);
$this->dispatch('loadData',$plantId, $state, '', '');
}),
Select::make('year')
->label('Year')
->reactive()
@@ -97,9 +56,13 @@ class ProductionTarget extends Page
->required()
->afterStateUpdated(function ($state, callable $get, $set) {
$set('month', null);
$set('plant_id', null);
$set('line_id', null);
$set('category', null);
$plantId = $get('plant_id');
$lineId = $get('line_id');
$this->dispatch('loadData',$plantId, $lineId, $state, '');
// $this->dispatch('loadData',$plantId, $lineId, $state, '');
$this->dispatch('loadData',$state, '', '', '', '');
}),
Select::make('month')
@@ -121,23 +84,86 @@ class ProductionTarget extends Page
'12' => 'December',
])
->required()
->afterStateUpdated(function ($state, callable $get) {
->afterStateUpdated(function ($state, callable $get, $set) {
$set('plant_id', null);
$set('line_id', null);
$set('category', null);
$year = $get('year');
$this->dispatch('loadData',$year, $state, '', '', '');
// $plantId = $get('plant_id');
// $lineId = $get('line_id');
// // $month = $get('month');
// $year = $get('year');
// $month = (int) $get('month');
// if (!$month) {
// return;
// }
// $this->dispatch('loadData', $plantId, $lineId, $month, $year);
}),
Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->reactive()
// ->searchable()
->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();
})
->required()
->afterStateUpdated(function ($state, callable $get, $set) {
// dd($state);
$set('line_id', null);
$set('category', null);
$this->dispatch('loadData',$state, '', '', '', '');
}),
Select::make('line_id')
->label('Line')
->required()
->relationship('line', 'name')
// ->searchable()
->columnSpan(1)
->options(function (callable $get) {
if (!$get('plant_id')) {
return [];
}
return \App\Models\Line::where('plant_id', $get('plant_id'))
->pluck('name', 'id')
->toArray();
})
->reactive()
->afterStateUpdated(function ($state, callable $get, $set) {
$plantId = $get('plant_id');
$lineId = $get('line_id');
// $month = $get('month');
$year = $get('year');
$month = (int) $get('month');
$this->dispatch('loadData',$year, $month, $plantId, $lineId, '');
}),
if (!$month) {
return;
}
$this->dispatch('loadData', $plantId, $lineId, $month, $year);
TextInput::make('category')
->label('Category')
->reactive()
->afterStateUpdated(function ($state, callable $get, $set) {
$plantId = $get('plant_id');
$lineId = $get('line_id');
// $month = $get('month');
$year = $get('year');
$month = (int) $get('month');
$category = $get('category');
$this->dispatch('loadData',$year, $month, $plantId, $lineId, $category);
}),
])
->columns(4)
->columns(5)
]);
}