Unique Slug (2 Columns)

I want to check the slug column and parent_id column. I pulled the old validation ruleset if that helps, but I have no idea how to do this in Filament.
'slug' => 'alpha_dash|unique:ea_series,slug,NULL,id,parent_id,'.$request->parent_id,
'slug' => 'alpha_dash|unique:ea_series,slug,NULL,id,parent_id,'.$request->parent_id,
4 Replies
krekas
krekas2y ago
Filament
Validation - Form Builder - Filament
The elegant TALL stack form builder for Laravel artisans.
Mack H
Mack HOP2y ago
Forms\Components\TextInput::make('slug')
->placeholder('Slug')
->unique(ignoreRecord: true, callback: function (Unique $rule) {
return $rule->where('parent_id', 0);
}),
Forms\Components\TextInput::make('slug')
->placeholder('Slug')
->unique(ignoreRecord: true, callback: function (Unique $rule) {
return $rule->where('parent_id', 0);
}),
I just need to figure out how to get the value of the select parent_id instead of 0.
awcodes
awcodes2y ago
Look up ‘closure customization’ in the docs.
Mack H
Mack HOP2y ago
Sheesh thank you!
Forms\Components\TextInput::make('slug')
->placeholder('Slug')
->unique(ignoreRecord: true, callback: function (Unique $rule, Closure $get) {
$parent_id = $get('parent_id');
return $rule->where('parent_id', $parent_id);
}),
Forms\Components\TextInput::make('slug')
->placeholder('Slug')
->unique(ignoreRecord: true, callback: function (Unique $rule, Closure $get) {
$parent_id = $get('parent_id');
return $rule->where('parent_id', $parent_id);
}),
Want results from more Discord servers?
Add your server