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 Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Str;
|
||||||
|
|
||||||
class MachineResource extends Resource
|
class MachineResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -85,6 +87,13 @@ class MachineResource extends Resource
|
|||||||
}
|
}
|
||||||
else
|
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);
|
$set('mLineError', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -95,7 +104,17 @@ class MachineResource extends Resource
|
|||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\TextInput::make('name')
|
Forms\Components\TextInput::make('name')
|
||||||
->label('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')
|
Forms\Components\TextInput::make('id')
|
||||||
->hidden()
|
->hidden()
|
||||||
->readOnly(),
|
->readOnly(),
|
||||||
@@ -126,6 +145,11 @@ class MachineResource extends Resource
|
|||||||
->label('Name')
|
->label('Name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
|
Tables\Columns\TextColumn::make('work_center')
|
||||||
|
->label('Work Center')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->label('Created At')
|
->label('Created At')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
|||||||
Reference in New Issue
Block a user