Answer the question
In order to leave comments, you need to log in
What eloquent request can be made for a default field?
Here I have a field, in laravel nova, inside an article: Text::make(__('Field'), 'thing')
How can I set it to a default value from the same article, but from a different, previously entered field? I know it can be done like this:
Text::make(__('Field'), 'thing')->default(function ($request){
return DB::table('thing')->orderBy('id', 'desc')->first()->count;
}),
Answer the question
In order to leave comments, you need to log in
As part of the description of the fields, you have access $this
that refers to the model of the current object.
If count
this is just a field for the model, then it should work$this->count
Text::make(__('Field'), 'thing')->default(function ($request){
return $this->count;
}),
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question