Closed GitCodeCruiser closed 4 years ago
What's the response in ajax call, is there any error?
I've got the same issue and it's coming from there: https://github.com/the-control-group/voyager/blob/1.4/src/Http/Controllers/VoyagerBaseController.php#L873
If you use a scope, you have an Eloquent model and the ->additional_attributes
is raising an exception because it works only for model object.
I solved it by overriding the VoyagerBaseControler@relation method and changing this:
if (in_array($options->label, $model->additional_attributes ?? [])) {
by this:
if (in_array($options->label, app($options->model)->additional_attributes ?? [])) {
I think this is fixed here: https://github.com/the-control-group/voyager/pull/4875
Closed because no feedback was provided.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.
Version information
Description
When trying to filter a select results I'm getting "the results could not be loaded". I have a custom attribute in my relationship which is a result of a column from current table and a column from a table in relationship (eloquent relationships).
If I remove column of the table in relationship my custom attribute on Bread relationship filter works just fine.
Steps To Reproduce
Steps to reproduce the behavior:
Create a custom attribute on the model that includes an attribute of 2nd table using eloquent relationships eg. public $additional_attributes = ['full_name'];
public function getFullNameAttribute() { return "{$this->name} - {$this->district->name}"; } public function district() { return $this->belongsTo( District::class, 'district_id', 'id'); }
Create a relationship using voyger
Select the custom attribute on the relationship and save
Add new register on BREAD
Try to filter select results
Expected behavior
I understand that it's difficult to search in the second table but it must at-least let me filter based on the the current table value.
Screenshots
Additional context
In the screenshots above ملک غلام محمد is the value from current table and لاہور is the value from second table i.e. district