column('name', __('社区医院')); $type = request('product_type',5); $org_id = \Admin::user()->org_id; if(!empty($org_id)){ $grid->model()->where(['id'=>$org_id]); } $grid->column('orders', __('总订单数'))->display(function () use ($type) { return Order::where('organization_id',$this->id)->where('product_type',$type)->count(); }); $grid->column('ordering', __('进行中订单'))->where('product_type',$type)->display(function () use ($type) { return Order::where(['organization_id'=>$this->id,'order_status'=>3])->count(); }); $grid->column('is_ok', __('完成数量'))->display(function () use ($type) { return Order::where(['organization_id'=>$this->id,'order_status'=>4])->where('product_type',$type)->count(); }); $grid->column('anomaly', __('异常数量'))->display(function () use ($type) { return Order::where(['organization_id'=>$this->id])->where('product_type',$type)->orWhere('order_status',5)->orWhere('payment_status','>',2)->count(); }); $grid->filter(function ($filter){ $filter->disableIdFilter(); $filter->equal('id','机构')->select(Organization::pluck('name','id')->toArray()); }); $grid->actions(function ($actions) { $actions->disableEdit(); $actions->disableView(); $actions->disableDelete(); }); return $grid; } }