• laravel 预加载特定的列


    /**订单列表 0 已删除   1执行中   2 已过期
    *
    * @param Request $request
    *
    * @return IlluminateContractsViewFactory|IlluminateViewView
    * @author lxw
    */
    public function getOrderList( Request $request )
    {
    $this->closeSqlFullMode();
    $query = $this->buildingPayment->query();
    $status = $request['status'] ?? '1';
    switch( $status ) {
    case '1': //执行中
    $query->whereDate('duetime', '>', date('Y-m-d', time()));
    break;
    case '2': //已到期
    $query->whereDate('duetime', '<=', date('Y-m-d', time()));
    break;
    case '0': //已删除
    $query->onlyTrashed();
    break;
    default:
    $query->whereDate('duetime', '>', date('Y-m-d', time()));
    }
    // $orderLists = $query->groupBy('order_id')->orderBy('created_at', 'desc')->paginate(env('PAGE_LIMIT'));
    //优化后
    $orderLists = $query->groupBy('order_id')->with(['companies:id,username','manages:id,username','buildings:id,name'])->orderBy('created_at', 'desc')->paginate(env('PAGE_LIMIT'));


    return view('Manage.Payment.PaymentList', ['orderLists' => $orderLists, 'links' => ['status' => $status]]);
    }

    
    
  • 相关阅读:
    django序列化器Serializers
    django中模型类变更问题
    django图书管理系统-外键字段的增删改查
    django图书管理系统模型创建
    django中使用KindEditor上传图片
    成长
    git提交代码的经验
    react项目打包
    node——moudle
    git
  • 原文地址:https://www.cnblogs.com/lxwphp/p/10785742.html
Copyright © 2020-2023  润新知