OrganizationController.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Community\Controllers;
  3. use App\Admin\Actions\Cdmuser;
  4. use App\Admin\Actions\UpdateCdms;
  5. use App\Models\Area;
  6. use App\Models\Order;
  7. use App\Models\Organization;
  8. use Encore\Admin\Controllers\AdminController;
  9. use Encore\Admin\Form;
  10. use Encore\Admin\Grid;
  11. use Encore\Admin\Show;
  12. class OrganizationController extends AdminController
  13. {
  14. /**
  15. * Title for current resource.
  16. *
  17. * @var string
  18. */
  19. protected $title = '计免服务';
  20. /**
  21. * Make a grid builder.
  22. *
  23. * @return Grid
  24. */
  25. protected function grid()
  26. {
  27. $grid = new Grid(new Organization());
  28. $grid->column('name', __('社区医院'));
  29. $type = request('product_type',4);
  30. $grid->column('orders', __('总订单数'))->display(function () use ($type) {
  31. return Order::where('organization_id',$this->id)->where('product_type',$type)->count();
  32. });
  33. $grid->column('ordering', __('进行中订单'))->where('product_type',$type)->display(function () use ($type) {
  34. return Order::where(['organization_id'=>$this->id,'order_status'=>3])->count();
  35. });
  36. $grid->column('is_ok', __('完成数量'))->display(function () use ($type) {
  37. return Order::where(['organization_id'=>$this->id,'order_status'=>4])->where('product_type',$type)->count();
  38. });
  39. $grid->column('anomaly', __('异常数量'))->display(function () use ($type) {
  40. return Order::where(['organization_id'=>$this->id])->where('product_type',$type)->orWhere('order_status',5)->orWhere('payment_status','>',2)->count();
  41. });
  42. $grid->filter(function ($filter){
  43. $filter->disableIdFilter();
  44. $filter->equal('id','机构')->select(Organization::pluck('name','id')->toArray());
  45. });
  46. $grid->actions(function ($actions) {
  47. $actions->disableEdit();
  48. $actions->disableView();
  49. $actions->disableDelete();
  50. });
  51. return $grid;
  52. }
  53. }