I dont know if I got you right , but it looks like you need to use when() or an if to choose which query to call
Jul 31, 2022
9
Level 1
Multiple filtering data with Model::query()
Hello , I'm so so sorry for title if it's bad I couldn't find better one :D
My problem is I want to show a data from db but with multiple filtering
I'm doing it with model::query() now but I have a big problem
this is my code:
$qry = Raid::query();
$first = $qry->whereIn('status', [1,4])->where('type_id', 1)->paginate(20, ['*'], 'first');
$second = $qry->whereIn('status', [1,4])->where('type_id', 2)->paginate(20, ['*'], 'second');
problem is $second is not showing the correct data because in the $first line , it applies the filter so the second one is using first one too
I have to show multiple data in one page and I have pagination for all of them so I have to paginate them one by one
Is there anyway to do it without calling Model multiple times? because it's 12 different variable at max so it's not possible to call eloquent 12 time :D
Thanks in advance
Please or to participate in this conversation.