Refactor plant selection options by authenticated user's plant ID.
This commit is contained in:
@@ -122,11 +122,15 @@ class StickerReprint extends Page implements HasForms
|
||||
->schema([
|
||||
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
->columnSpan(1)
|
||||
//->options(Plant::pluck('name', 'id'))
|
||||
->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();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(ProductionQuantity::latest()->first())->plant_id;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user