Refactor plant selection options by authenticated user's plant ID.
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Models\Plant;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\QualityValidation;
|
||||
use App\Models\StickerMaster;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\Actions;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Form;
|
||||
@@ -55,8 +56,12 @@ class DataSendToSap extends Page implements HasForms
|
||||
->statePath('data')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Plant')
|
||||
// ->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();
|
||||
})
|
||||
->reactive()
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, $set, callable $get) {
|
||||
|
||||
Reference in New Issue
Block a user