This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello,
I am using the boot()
method in my own plugin to extend an existing form in another plugin using Event::listen('backend.form.extendFields', function($widget) {})
. I am able to add regular fields, but once I try to add a featured_image
field of type fileupload
, I get the following error:
Call to undefined method Illuminate\Database\Query\Builder::featured_image()
What's causing this?
Last updated
You probably need to also extend the target model with the file relationship. Try adding something like this to your boot method.
ModelBeingExtended::extend(function ($model) {
$model->attachOne['featured_image'] = ['System\Models\File'];
});
Yes, I had already did that, but the problem seemed to be quite trivial: I was extending the model inside the anonymous function that was being passed to Event::listen(). I moved it out of there and it started working as expected.
Last updated
1-3 of 3