unique Validation two colums How do it
I have two columns I wanaa unique Validation in textinput
4 Replies
https://laravel.com/docs/10.x/validation#rule-unique
or
https://filamentphp.com/docs/3.x/forms/validation#custom-rules
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
I have two columns, if one value differs, OK, if the two values do not differ, Validation works
'name' => [
'required',
'unique:domains,name',
Rule::unique('domains', 'name')->where('compliance_id', $this->input('compliance_id')),
],
Where I can write this code
I solved Forms\Components\TextInput::make('name')
->unique(modifyRuleUsing: function (Unique $rule, callable $get) { // $get callable is used
return $rule
->where('compliance_id', $get('compliance_id'))
->where('name', $get('name'));
}, ignoreRecord: true)