Added work_center column in resource file
This commit is contained in:
@@ -19,6 +19,8 @@ use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Str;
|
||||
|
||||
class MachineResource extends Resource
|
||||
{
|
||||
@@ -85,6 +87,13 @@ class MachineResource extends Resource
|
||||
}
|
||||
else
|
||||
{
|
||||
$grpWrkCnr = Line::find($lineId)->group_work_center;
|
||||
if (!$grpWrkCnr || Str::length($grpWrkCnr) < 1)
|
||||
{
|
||||
$set('mLineError', 'Please select a group work center line.');
|
||||
$set('line_id', null);
|
||||
return;
|
||||
}
|
||||
$set('mLineError', null);
|
||||
}
|
||||
})
|
||||
@@ -95,7 +104,17 @@ class MachineResource extends Resource
|
||||
->hintColor('danger'),
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label('Name')
|
||||
->required(),
|
||||
->placeholder('Scan the valid Machine Name')
|
||||
->required()
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('machines', 'name')
|
||||
->where('line_id', $get('line_id'))
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
Forms\Components\TextInput::make('work_center')
|
||||
->label('Work Center')
|
||||
->placeholder('Scan the valid Work Center'),
|
||||
Forms\Components\TextInput::make('id')
|
||||
->hidden()
|
||||
->readOnly(),
|
||||
@@ -126,6 +145,11 @@ class MachineResource extends Resource
|
||||
->label('Name')
|
||||
->searchable()
|
||||
->alignCenter(),
|
||||
Tables\Columns\TextColumn::make('work_center')
|
||||
->label('Work Center')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
|
||||
Reference in New Issue
Block a user