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 App\Models\Machine;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Filament\Forms; use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Resources\Resource; use Filament\Resources\Resource;
use Filament\Tables; use Filament\Tables;
@@ -25,14 +26,21 @@ class CharacteristicApproverMasterResource extends Resource
public static function form(Form $form): Form public static function form(Form $form): Form
{ {
return $form return $form
->schema([
Section::make('')
->schema([ ->schema([
Forms\Components\Select::make('plant_id') Forms\Components\Select::make('plant_id')
->label('Plant') ->label('Plant')
->columnSpan(2)
->reactive() ->reactive()
->relationship('plant', 'name') ->relationship('plant', 'name')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(), ->required(),
Forms\Components\Select::make('machine_id') Forms\Components\Select::make('machine_id')
->label('Work Center') ->label('Work Center')
->columnSpan(2)
// ->relationship('machine', 'name') // ->relationship('machine', 'name')
->reactive() ->reactive()
->searchable() ->searchable()
@@ -44,35 +52,100 @@ class CharacteristicApproverMasterResource extends Resource
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id'); return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
}) })
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(), ->required(),
Forms\Components\TextInput::make('characteristic_field') Forms\Components\TextInput::make('characteristic_field')
->label('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') Forms\Components\TextInput::make('machine_name')
->label('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') Forms\Components\TextInput::make('name1')
->label('Name-1'), ->label('Name')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('mail1') Forms\Components\TextInput::make('mail1')
->label('Mail-1'), ->label('Mail')
->columnSpan(['default' => 1, 'sm' => 2])
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('duration1') Forms\Components\TextInput::make('duration1')
->label('Duration-1 (Hour.Minute)'), ->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') Forms\Components\TextInput::make('name2')
->label('Name-2'), ->label('Name')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('mail2') Forms\Components\TextInput::make('mail2')
->label('Mail-2'), ->label('Mail')
->columnSpan(['default' => 1, 'sm' => 2])
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('duration2') Forms\Components\TextInput::make('duration2')
->label('Duration-2 (Hour.Minute)'), ->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') Forms\Components\TextInput::make('name3')
->label('Name-3'), ->label('Name')
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('mail3') Forms\Components\TextInput::make('mail3')
->label('Mail-3'), ->label('Mail')
->columnSpan(['default' => 1, 'sm' => 2])
->afterStateUpdated(function ($state, callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('duration3') Forms\Components\TextInput::make('duration3')
->label('Duration-3 (Hour.Minute)'), ->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') Forms\Components\Hidden::make('created_by')
->label('Created By') ->label('Created By')
->default(Filament::auth()->user()?->name), ->default(Filament::auth()->user()?->name),
Forms\Components\Hidden::make('updated_by') Forms\Components\Hidden::make('updated_by')
->label('Updated By') ->label('Updated By')
->default(Filament::auth()->user()?->name), ->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') Tables\Columns\TextColumn::make('plant.name')
->label('Plant') ->label('Plant')
->alignCenter() ->alignCenter()
->searchable()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('machine.work_center') Tables\Columns\TextColumn::make('machine.work_center')
->label('Work Center') ->label('Work Center')
->alignCenter() ->alignCenter()
->searchable()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('characteristic_field') Tables\Columns\TextColumn::make('characteristic_field')
->label('Characteristic Field') ->label('Characteristic Field')
->alignCenter() ->alignCenter()
->searchable()
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
->extraAttributes(['class' => 'uppercase'])
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('machine_name') Tables\Columns\TextColumn::make('machine_name')
->label('Machine Name') ->label('Machine Name')
->alignCenter() ->alignCenter()
->searchable()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('name1') Tables\Columns\TextColumn::make('name1')
->label('Approver Name 1') ->label('Approver Name 1')
->alignCenter() ->alignCenter()
->searchable()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('mail1') Tables\Columns\TextColumn::make('mail1')
->label('Mail 1') ->label('Mail 1')
->alignCenter() ->alignCenter()
->searchable()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('duration1') Tables\Columns\TextColumn::make('duration1')
->label('Duration 1 (Hour.Minute)') ->label('Duration 1 (Hour.Minute)')
@@ -120,10 +201,12 @@ class CharacteristicApproverMasterResource extends Resource
Tables\Columns\TextColumn::make('name2') Tables\Columns\TextColumn::make('name2')
->label('Approver Name 2') ->label('Approver Name 2')
->alignCenter() ->alignCenter()
->searchable()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('mail2') Tables\Columns\TextColumn::make('mail2')
->label('Mail 2') ->label('Mail 2')
->alignCenter() ->alignCenter()
->searchable()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('duration2') Tables\Columns\TextColumn::make('duration2')
->label('Duration 2 (Hour.Minute)') ->label('Duration 2 (Hour.Minute)')
@@ -132,10 +215,12 @@ class CharacteristicApproverMasterResource extends Resource
Tables\Columns\TextColumn::make('name3') Tables\Columns\TextColumn::make('name3')
->label('Approver Name 3') ->label('Approver Name 3')
->alignCenter() ->alignCenter()
->searchable()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('mail3') Tables\Columns\TextColumn::make('mail3')
->label('Mail 3') ->label('Mail 3')
->alignCenter() ->alignCenter()
->searchable()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('duration3') Tables\Columns\TextColumn::make('duration3')
->label('Duration 3 (Hour.Minute)') ->label('Duration 3 (Hour.Minute)')
@@ -145,16 +230,31 @@ class CharacteristicApproverMasterResource extends Resource
->label('Created At') ->label('Created At')
->alignCenter() ->alignCenter()
->dateTime() ->dateTime()
->sortable() ->searchable()
->toggleable(isToggledHiddenByDefault: true), ->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('updated_at') Tables\Columns\TextColumn::make('updated_at')
->label('Updated At') ->label('Updated At')
->alignCenter() ->alignCenter()
->dateTime() ->dateTime()
->searchable()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_by')
->label('Updated By')
->alignCenter()
->searchable()
->sortable() ->sortable()
->toggleable(isToggledHiddenByDefault: true), ->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at') Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->dateTime() ->dateTime()
->alignCenter()
->searchable()
->sortable() ->sortable()
->toggleable(isToggledHiddenByDefault: true), ->toggleable(isToggledHiddenByDefault: true),
]) ])