2

尝试对内部连接进行分页,但它不起作用。

这是我的代码

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

这就是数组的样子(没有 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
    )

这就是我使用的

use DB;
use Illuminate\Support\Facades\Input;
use Illuminate\Http\Request;
use App\Http\Requests;
4

1 回答 1

1

paginate 与 get 方法不同,要么 get for all 要么 paginate for paginated get ,而不是两者。

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

于 2016-05-02T12:30:43.693 回答