Saikishore's avatar

Laravel scout - get results based on reference table where condition with pagination

Hi Team,

I am using "Scout" search. I am having two tables as "users", "user_profile". I am trying to get the users data based on "user_profile.age" = 35 .

foreign Key : user_id

$users = User::search($keyword)->paginate(4); $users->load(['user_profile' => function ($query) { $query->where('age', 35); }]);

Here what happend is results are showing 4 users data along with user profile data which is satisfying the where condition. If condition fails user profile data set is empty.

But I want only where condition satisfied records with pagination.

Can anybody help on this with pagination...

0 likes
1 reply

Please or to participate in this conversation.