【问题标题】:laravel api handler how to order by a child columnlaravel api处理程序如何按子列排序
【发布时间】:2018-03-02 12:13:42
【问题描述】:

我正在使用laravel API handler 我想知道如何通过“with”表中的列发送订购请求

这是我的后端代码

$query = Product::query();
    $query->company();
    $query->with('category'); $result=ApiHandler::parseMultiple($query);
    return $result->getResponse(); 

和请求网址

http://localhost/public/api/v1/product/view/0?&_offset=0&_limit=10&_config=meta-total-count,meta-filter-count&_sort=-category.category_name

【问题讨论】:

    标签: laravel-4


    【解决方案1】:
    $query = Product::getModel()
    ->newQuery()
    ->select('products.*','categories.*')
    ->join('categories','product.category_id,'=','categories.id')
    ->orderBy('category.sort_order');
    

    应该这样做。

    【讨论】:

      猜你喜欢
      • 2022-01-01
      • 2017-04-28
      • 1970-01-01
      • 1970-01-01
      • 2018-08-22
      • 2021-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多