如何在内部连接上使用 ->paginate() 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 all 要么 paginate for paginated get not both.

删除 get,它将起作用。 https://laravel.com/docs/5.2/pagination