How to deal with BelongsToMany relation? #81
Unanswered
carlos-talavera
asked this question in
Q&A
Replies: 2 comments
-
Hi @carlos-talavera. I am happy that purity came in handy for you. you should define /**
* The attributes that are filterable.
*
* @var array<string, string>
*/
protected $filterFields = [
'id_area'
]; in |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @abbasudo, thanks for your answer. Unfortunately it doesn't work because the relation is like this But if I try filtering by using ->when(isset($request->query('filters')['areas']['id_area']['$eq']), function ($query) use ($request) {
$id_area = $request->query('filters')['areas']['id_area']['$eq'];
$query->whereHas('areas', function ($query) use ($id_area) {
$query->where('id_area', $id_area);
});
}) Just to build the query as if I was using Purity |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, this is a wonderful library and I've been using extensively on my project, but now I'm facing this issue and don't find how to do it right. I have this relation on a InsumoProduccion (ProductionInput) model to get the productive areas that the input belongs to:
I want to filter it based on the ID of the area. The corresponding model of the pivot table is this:
I'm trying with something like this (in JS):
But it doesn't work, it brings all the records. I'd appreciate any idea or hint you could give me, thanks!
Beta Was this translation helpful? Give feedback.
All reactions