Added combined unique and default value
This commit is contained in:
@@ -48,6 +48,9 @@ class ProductionLineStopResource extends Resource
|
||||
->required()
|
||||
// ->nullable()
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(ProductionLineStop::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => !empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_name', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
@@ -82,23 +85,18 @@ class ProductionLineStopResource extends Resource
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
// ->default(function (callable $get, callable $set) {
|
||||
// if ($get('id')) {
|
||||
// $getShift = ProductionLineStop::where('id', $get('id'))->first();
|
||||
// $getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
||||
// // dd($getBlock->block_id);
|
||||
// $set('block_name', $getBlock->block_id);
|
||||
// }
|
||||
// // return null; // Return null if no default value should be set
|
||||
// })
|
||||
->default(function () {
|
||||
$latestShiftId = optional(ProductionLineStop::latest()->first())->shift_id;
|
||||
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
|
||||
})
|
||||
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
$getShift = ProductionLineStop::where('id', $get('id'))->first();
|
||||
// $getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
||||
$getBlock = Shift::where('id', $getShift->shift_id)->first();
|
||||
if($getBlock->block_id)
|
||||
// $getBlock = \App\Models\Shift::where('id', $getShift->shift_id)->first();
|
||||
$getBlock = Shift::where('id', $getShift->shift_id)->first();
|
||||
if($getBlock->block_id)
|
||||
{
|
||||
$set('block_name', $getBlock->block_id);
|
||||
$set('plsBlockError', null);
|
||||
@@ -137,6 +135,9 @@ class ProductionLineStopResource extends Resource
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(ProductionLineStop::latest()->first())->shift_id;
|
||||
})
|
||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
@@ -181,6 +182,9 @@ class ProductionLineStopResource extends Resource
|
||||
->toArray();
|
||||
})
|
||||
->reactive()
|
||||
->default(function () {
|
||||
return optional(ProductionLineStop::latest()->first())->line_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if($get('id'))
|
||||
{
|
||||
@@ -481,7 +485,8 @@ class ProductionLineStopResource extends Resource
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(ProductionLineStopImporter::class),
|
||||
->importer(ProductionLineStopImporter::class)
|
||||
->maxRows(100000),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user