UsmanBasharmal
2 weeks ago

Call to a member function paginate() on array

Posted 2 weeks ago by UsmanBasharmal

I am using a raw query as shown below in BookController and making paginate(5) as shown below. But it throws this error "Call to a member function paginate() on array". Any solution, please.

 public function index()
        {
            try {
                $Book = DB::select('select b.id as id ,b.name as bk,c.name as Catagory,(select name from author_translators WHERE id = b.author_id) as Author,(select name from author_translators WHERE id = b.translate_id)as Translator,l.name as Language,pb.name as Publisher,b.publishing_date,b.edition,b.valume_number,b.ISBN from books b join categories c on b.category_id = c.id join publishers pb on b.publisher_id = pb.id join languages l on b.language_id = l.id')
               ->paginate(5);             
                return response()->json($Book);
            } catch (Exception $e) {
                return response()->json($e->getMessage(), 500);
            }
        }

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