Added unique validation on resource file
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
This commit is contained in:
@@ -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(),
|
||||||
|
|||||||
Reference in New Issue
Block a user