ranjith-dev #349
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\LineExporter;
|
use App\Filament\Exports\LineExporter;
|
||||||
use App\Filament\Imports\LineImporter;
|
use App\Filament\Imports\LineImporter;
|
||||||
use App\Filament\Resources\LineResource\Pages;
|
use App\Filament\Resources\LineResource\Pages;
|
||||||
|
use App\Models\Block;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\WorkGroupMaster;
|
use App\Models\WorkGroupMaster;
|
||||||
@@ -71,6 +72,38 @@ class LineResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('lPlantError') ? $get('lPlantError') : null)
|
->hint(fn ($get) => $get('lPlantError') ? $get('lPlantError') : null)
|
||||||
->hintColor('danger'),
|
->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')
|
Forms\Components\TextInput::make('name')
|
||||||
->required()
|
->required()
|
||||||
->placeholder('Scan the valid name')
|
->placeholder('Scan the valid name')
|
||||||
@@ -1012,6 +1045,11 @@ class LineResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
Tables\Columns\TextColumn::make('block.name')
|
||||||
|
->label('Block')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('name')
|
Tables\Columns\TextColumn::make('name')
|
||||||
->label('Line')
|
->label('Line')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
|||||||
Reference in New Issue
Block a user