0

I have a query that i am trying to insert a value based on a forum post results. Boiling it down to this

$users->whereIn('id', $viewedIds);
$rdata = $users->with('profile')->where('gender', '=', $searchGender)->orderBy('last_login')->simplePaginate(8);

Which doesn't work. but this does.

$rdata = $users->with('profile')->where('gender', '=', $searchGender)->whereIn('id', $viewedIds)->orderBy('last_login')->simplePaginate(8);

but I cant do that with form post data.

Any ideas?

Terre Porter
  • 63
  • 2
  • 9
  • Does this answer your question? [Laravel where on relationship object](https://stackoverflow.com/questions/29989908/laravel-where-on-relationship-object) – Ron van der Heijden Mar 06 '22 at 19:14
  • `with` can be used during queries before get/first/all, but `load` can work on initiated query, like your stack of queries. – iazaran Mar 06 '22 at 19:21
  • Ron - it helps but they way they are using the eloquent model is different and they are not adding on to a existing query. – Terre Porter Mar 06 '22 at 19:49

1 Answers1

0

I needed to start my query with $users = User::query() instead of $users = new User();

Terre Porter
  • 63
  • 2
  • 9