如何->;在内部联接Laravel 5上分页()


how to ->paginate() on a inner join Laravel 5

试图对内部联接进行分页,但不起作用。

这是我的代码

    $positions = DB::table('position')
    ->join('company', 'position.company_id', '=', 'company.id')
    ->select('position.*', 'company.name')
    ->paginate(15)
    ->get();

这就是数组的样子(没有分页->())

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
    )

这就是我使用的

use DB;
use Illuminate'Support'Facades'Input;
use Illuminate'Http'Request;
use App'Http'Requests;

paginate与get方法不同,要么get for all,要么paginate for paginated get not both。

移除get,它就会工作。https://laravel.com/docs/5.2/pagination