<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Exam;
use App\Module;
use App\Dapartment;
use DB;
class PastexController extends Controller
{
//
public function index()
{
$xams=DB::table('exams')
->join('modules', 'modules.id', '=', 'exams.module_code_id')
->where('exams.views', '!=', '0')
->select('exams.views','modules.name_of_modue', 'modules.code','exams.id','exams.yr', 'exams.month')
->get()->sortByDesc('views')
->paginate(7);
return view('pastex/home', ['xams'=>$xams]);
}
}
This is the error message I m getting BadMethodCallException Method Illuminate\Support\Collection::paginate does not exist.
Using
get()
returns a collection, whilepaginate
belongs to the Query Builder. You'll need to usepaginate
instead ofget
, and move the ordering to the query builder instead of the collection.