Added unique validation on resource file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

This commit is contained in:
dhanabalan
2026-04-02 12:10:04 +05:30
parent 6c3c7094ce
commit 43694dc5de

View File

@@ -19,6 +19,7 @@ use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope; use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Validation\Rule;
class ConfigurationResource extends Resource class ConfigurationResource extends Resource
{ {
@@ -107,7 +108,16 @@ class ConfigurationResource extends Resource
->required(), ->required(),
Forms\Components\TextInput::make('c_value') Forms\Components\TextInput::make('c_value')
->label('Value') ->label('Value')
->required(), ->required()
->rule(function (callable $get) {
return Rule::unique('configurations', 'c_value')
->where('plant_id', $get('plant_id'))
->where('line_id', $get('line_id'))
->where('c_type', $get('c_type'))
->where('c_group', $get('c_group'))
->where('c_name', $get('c_name'))
->ignore($get('id')); // Ignore current record during updates
}),
Forms\Components\TextInput::make('id') Forms\Components\TextInput::make('id')
->hidden() ->hidden()
->readOnly(), ->readOnly(),