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
public function author(): BelongsTo
{
return $this->belongsTo(User::class, 'owner_id');
}
And when I try to ->toSql() the output, it return the sql query like this:
select * from articles .... and exists (select * from `users` where `articles`.`owner_id` = `users`.`id` and `users.slug`='....');
The query builder affected by the author() method in Article model because of this AllowedFilter::exact('author_slug', 'author.slug') when apply filtering query string in API /articles?filter[authors_slug]=XXXX
After I rename the author(): BelongsTo method in Article model, now the sql query become this:
select * from articles ... where `users.slug`='....';
Is this magic or bug? Anyone encounter this strange behavior before? Thanks.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I have a question about spatie query builder AllowedFilter.
In my Article model I have this method:
And when I try to
->toSql()
the output, it return the sql query like this:The query builder affected by the
author()
method in Article model because of thisAllowedFilter::exact('author_slug', 'author.slug')
when apply filtering query string in API/articles?filter[authors_slug]=XXXX
After I rename the
author(): BelongsTo
method in Article model, now the sql query become this:Is this magic or bug? Anyone encounter this strange behavior before? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions