【问题标题】:Yajra DataTables orderColumn on eloquent doesn't work雄辩的 Yajra DataTables orderColumn 不起作用
【发布时间】:2020-04-02 08:34:55
【问题描述】:

我在我的 Laravel 7 项目中使用 Yajra DataTables。我在 orderColumn API 上有问题。这是我的代码:

return Datatables::eloquent(Company::query())
        ->orderColumn('name', '`column` $1')
        ->make();

但是生成的查询是:

select * from `companies` where `companies`.`deleted_at` is null order by `id` asc limit 10 offset 0

谁能帮帮我?

【问题讨论】:

    标签: laravel datatables yajra-datatable


    【解决方案1】:

    我知道为时已晚,但我也遇到了这个问题,并用这段代码解决了这个问题

    return Datatables::eloquent(Company::query())
        ->order(funtion($q){
            $q->orderBy('colName', 'desc');
        })
        ->toJson();
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-26
      • 2016-03-07
      • 2023-04-07
      • 2015-06-25
      • 2019-08-13
      • 2015-02-25
      相关资源
      最近更新 更多