Refactor CharacteristicApproverMasterResource form structure and enhance table columns for improved usability and search functionality
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 19s
Laravel Pint / pint (pull_request) Successful in 5m27s
Laravel Larastan / larastan (pull_request) Failing after 5m36s

This commit is contained in:
dhanabalan
2026-01-27 15:54:37 +05:30
parent 11d48a7a91
commit c8bfbb122b

View File

@@ -7,6 +7,7 @@ use App\Models\CharacteristicApproverMaster;
use App\Models\Machine;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
@@ -26,53 +27,125 @@ class CharacteristicApproverMasterResource extends Resource
{
return $form
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->reactive()
->relationship('plant', 'name')
->required(),
Forms\Components\Select::make('machine_id')
->label('Work Center')
// ->relationship('machine', 'name')
->reactive()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return [];
}
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->columnSpan(2)
->reactive()
->relationship('plant', 'name')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\Select::make('machine_id')
->label('Work Center')
->columnSpan(2)
// ->relationship('machine', 'name')
->reactive()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return [];
}
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
})
->required(),
Forms\Components\TextInput::make('characteristic_field')
->label('Characteristic Field'),
Forms\Components\TextInput::make('machine_name')
->label('Machine Name'),
Forms\Components\TextInput::make('name1')
->label('Name-1'),
Forms\Components\TextInput::make('mail1')
->label('Mail-1'),
Forms\Components\TextInput::make('duration1')
->label('Duration-1 (Hour.Minute)'),
Forms\Components\TextInput::make('name2')
->label('Name-2'),
Forms\Components\TextInput::make('mail2')
->label('Mail-2'),
Forms\Components\TextInput::make('duration2')
->label('Duration-2 (Hour.Minute)'),
Forms\Components\TextInput::make('name3')
->label('Name-3'),
Forms\Components\TextInput::make('mail3')
->label('Mail-3'),
Forms\Components\TextInput::make('duration3')
->label('Duration-3 (Hour.Minute)'),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->label('Updated By')
->default(Filament::auth()->user()?->name),
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
})
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\TextInput::make('characteristic_field')
->label('Characteristic Field')
->columnSpan(2)
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('machine_name')
->label('Machine')
->columnSpan(2)
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Section::make('Approver - 1')
// ->description('Prevent abuse by limiting the number of requests per period')
->columnSpan(['default' => 2, 'sm' => 4])
->schema([
Forms\Components\TextInput::make('name1')
->label('Name')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('mail1')
->label('Mail')
->columnSpan(['default' => 1, 'sm' => 2])
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('duration1')
->label('Duration (HH.MM)')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
])
->collapsed()// collapsible()
->columns(['default' => 1, 'sm' => 4]),
Section::make('Approver - 2')
->columnSpan(['default' => 2, 'sm' => 4])
->schema([
Forms\Components\TextInput::make('name2')
->label('Name')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('mail2')
->label('Mail')
->columnSpan(['default' => 1, 'sm' => 2])
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('duration2')
->label('Duration (HH.MM)')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
])
->collapsed()// collapsible()
->columns(['default' => 1, 'sm' => 4]),
Section::make('Approver - 3')
->columnSpan(['default' => 2, 'sm' => 4])
->schema([
Forms\Components\TextInput::make('name3')
->label('Name')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('mail3')
->label('Mail')
->columnSpan(['default' => 1, 'sm' => 2])
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('duration3')
->label('Duration (HH.MM)')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
])
->collapsed()// collapsible()
->columns(['default' => 1, 'sm' => 4]),
Forms\Components\Hidden::make('created_by')
->label('Created By')
->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by')
->label('Updated By')
->default(Filament::auth()->user()?->name),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
])
->columns(['default' => 1, 'sm' => 4]),
]);
}
@@ -92,26 +165,34 @@ class CharacteristicApproverMasterResource extends Resource
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('machine.work_center')
->label('Work Center')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('characteristic_field')
->label('Characteristic Field')
->alignCenter()
->searchable()
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
->extraAttributes(['class' => 'uppercase'])
->sortable(),
Tables\Columns\TextColumn::make('machine_name')
->label('Machine Name')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('name1')
->label('Approver Name 1')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('mail1')
->label('Mail 1')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('duration1')
->label('Duration 1 (Hour.Minute)')
@@ -120,10 +201,12 @@ class CharacteristicApproverMasterResource extends Resource
Tables\Columns\TextColumn::make('name2')
->label('Approver Name 2')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('mail2')
->label('Mail 2')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('duration2')
->label('Duration 2 (Hour.Minute)')
@@ -132,10 +215,12 @@ class CharacteristicApproverMasterResource extends Resource
Tables\Columns\TextColumn::make('name3')
->label('Approver Name 3')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('mail3')
->label('Mail 3')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('duration3')
->label('Duration 3 (Hour.Minute)')
@@ -145,16 +230,31 @@ class CharacteristicApproverMasterResource extends Resource
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->alignCenter()
->dateTime()
->searchable()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->alignCenter()
->searchable()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->dateTime()
->alignCenter()
->searchable()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])