Trying to paginate a inner join but it does not work.
This it my code
$positions = DB::table('position')
->join('company', 'position.company_id', '=', 'company.id')
->select('position.*', 'company.name')
->paginate(15)
->get();
This is what the array looks like (without the paginate->())
Array(
[0] => stdClass Object
(
[id] => 1
[company_id] => 1
[title] => Software Developer
)
[1] => stdClass Object
(
[id] => 2
[company_id] => 2
[title] => Accountant
)
[2] => stdClass Object
(
[id] => 3
[company_id] => 3
[title] => Insurance salesman
)
and this is what i use
use DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Http\Request;
use App\Http\Requests;
paginate is different than get method either get for all or paginate for paginated get not both.
remove the get and it will work. https://laravel.com/docs/5.2/pagination