You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tag fields will populate with the incorrect resource when the resource holding the tag field was created via a relationship. This is presumable caused by line 30 of the Laravel\Nova\Http\Requests\ResourceSearchRequest class. Instead of $this->newQuery() one should presumable call $model->newQuery(), since $this->newQuery() is checking the "viaRelationship".
Admittedly, I do not oversee the consquences of such a change.
I think this is what the ResourceSearchRequest class should look like (it works for me):
<?phpnamespaceLaravel\Nova\Http\Requests;
useLaravel\Nova\Contracts\QueryBuilder;
class ResourceSearchRequest extends NovaRequest
{
use QueriesResources;
/** * Get the paginator instance for the index request. * * @return \Illuminate\Database\Eloquent\Collection */publicfunctionsearchIndex()
{
$resource = $this->resource();
$model = $this->model();
$limit = $resource::usesScout()
? $resource::$scoutSearchResults
: $resource::$relatableSearchResults;
$query = app()->make(QueryBuilder::class, [$resource]);
$this->first === 'true'
? $query->whereKey($model->newQueryWithoutScopes(), $this->current)
: $query->search(
$this, $model->newQuery(), $this->search,
$this->filters()->all(), $this->orderings(), $this->trashed()
);
return$query->take($limit)->get();
}
}
Detailed steps to reproduce the issue on a fresh Nova installation:
Create a parent resource that has some kind of child relation (e.g. a HasMany relation).
Create the child resource that has a tag field. The tag field should reference some kind of tag resource that I will refer to as "SomeTag".
Make sure there are a few tags in the "SomeTag" table.
Now when you search the tag field for available SomeTag's, it will show parent resources instead.
The text was updated successfully, but these errors were encountered:
Please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)
This issue can be closed. After researching the issue for over a day I figured that it was caused by a partner module. The "viaRelationship" query parameter and others were included in nova API requests. I wasn't aware that Nova itself does not include these parameters with API requests. Sorry for me opening this bug report in the first place and sorry for any inconveniences it may have caused.
Description:
Tag fields will populate with the incorrect resource when the resource holding the tag field was created via a relationship. This is presumable caused by line 30 of the
Laravel\Nova\Http\Requests\ResourceSearchRequest
class. Instead of$this->newQuery()
one should presumable call$model->newQuery()
, since$this->newQuery()
is checking the "viaRelationship".Admittedly, I do not oversee the consquences of such a change.
I think this is what the
ResourceSearchRequest
class should look like (it works for me):Detailed steps to reproduce the issue on a fresh Nova installation:
The text was updated successfully, but these errors were encountered: