【问题标题】:how to ->paginate() on a inner join Laravel 5如何在内部连接 ​​Laravel 5 上 ->paginate()
【发布时间】:2016-08-27 04:33:44
【问题描述】:

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

这是我的代码

    $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;

【问题讨论】:

    标签: php laravel-5 pagination laravel-paginate


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-21
      • 1970-01-01
      • 2015-07-10
      • 2015-02-17
      • 1970-01-01
      • 2021-06-28
      • 1970-01-01
      相关资源
      最近更新 更多