ruhulamin
2 weeks ago
104
3
Laravel

Pagination issue with Search query

Posted 2 weeks ago by ruhulamin

Hi,

I want to add the pagination in my search query. But I a confused how to use pagination along with Join tables.

Here is my query.

$user = CareerSolution::where ( 'subject', 'LIKE', '%' . $q . '%' )
                      ->where('career_solutions.topic_category_id', '=', $c)
        ->join('role_users' , 'role_users.user_id', '=', 'career_solutions.user_id')
        ->join('roles' , 'roles.id', '=', 'role_users.role_id')
        ->join('users', 'users.id', '=', 'career_solutions.user_id')
        ->join('categories', 'categories.id', '=', 'career_solutions.topic_category_id')
        ->orWhere ( 'career_solutions.user_id', 'LIKE', '%' . $q . '%' )
        ->orWhere ( 'career_solutions.id', '=', 'events.subject')
        ->orWhere('career_solutions.topic_category_id' ,'=', $category->id)
        ->orWhere ( 'career_solutions.user_id', '=', 'users.username')
       ->select('career_solutions.id as id','subject','users.id as user_id','username', 'profile_picture', 'role_id', 'optional', 'topic_category_id','categories.category')
         ->get ();

Please sign in or create an account to participate in this conversation.