Added block select box and line capacity in resource file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
||||
use App\Filament\Exports\LineExporter;
|
||||
use App\Filament\Imports\LineImporter;
|
||||
use App\Filament\Resources\LineResource\Pages;
|
||||
use App\Models\Block;
|
||||
use App\Models\Line;
|
||||
use App\Models\Plant;
|
||||
use App\Models\WorkGroupMaster;
|
||||
@@ -71,6 +72,38 @@ class LineResource extends Resource
|
||||
])
|
||||
->hint(fn ($get) => $get('lPlantError') ? $get('lPlantError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\Select::make('block_id')
|
||||
->label('Block')
|
||||
->relationship('block', 'name')
|
||||
->required()
|
||||
// ->nullable(),
|
||||
->reactive()
|
||||
->options(function (callable $get) {
|
||||
if (! $get('plant_id')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Block::where('plant_id', $get('plant_id'))
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(Block::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$blockId = $get('block_id');
|
||||
if (! $blockId) {
|
||||
$set('lblockError', 'Please select a Block first.');
|
||||
return;
|
||||
} else {
|
||||
$set('lblockError', null);
|
||||
}
|
||||
})
|
||||
->extraAttributes(fn ($get) => [
|
||||
'class' => $get('lblockError') ? 'border-red-500' : '',
|
||||
])
|
||||
->hint(fn ($get) => $get('lblockError') ? $get('lblockError') : null)
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->placeholder('Scan the valid name')
|
||||
@@ -1012,6 +1045,11 @@ class LineResource extends Resource
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('block.name')
|
||||
->label('Block')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Line')
|
||||
->alignCenter()
|
||||
|
||||
Reference in New Issue
Block a user