Accessing the current model inside custom validation rule
Hi. Is there a way to access the current model value inside the custom validation function?
I want to check if the model has children or not.
Forms\Components\Radio::make('status')
->options([
'draft' => 'Draft',
'public' => 'Public'
])
->descriptions([
'draft' => 'Will not be visible to students',
'public' => 'Will be visible to students'
])
->hiddenOn('create')
->default('draft')
->rules([
function () {
return function (string $attribute, $value, Closure $fail) {
// Here
};
}
])
->required(), Forms\Components\Radio::make('status')
->options([
'draft' => 'Draft',
'public' => 'Public'
])
->descriptions([
'draft' => 'Will not be visible to students',
'public' => 'Will be visible to students'
])
->hiddenOn('create')
->default('draft')
->rules([
function () {
return function (string $attribute, $value, Closure $fail) {
// Here
};
}
])
->required(),I want to check if the model has children or not.