海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\AdminSupplier\Lazys;
  3. use App\AdminSupplier\Extensions\Grid\ChooseDemand;
  4. use App\AdminSupplier\Repositories\DemandBidding;
  5. use App\Models\Demand;
  6. use App\Traits\DemandTraits;
  7. use Dcat\Admin\Grid;
  8. use Dcat\Admin\Grid\LazyRenderable;
  9. use Illuminate\Support\Arr;
  10. class DemandBiddingLazys extends LazyRenderable
  11. {
  12. public function grid(): Grid
  13. {
  14. return Grid::make(new DemandBidding(['biddingUser']), function (Grid $grid) {
  15. $demandId = request('demand_id','');
  16. $demand = Demand::find($demandId);
  17. $grid->model()->where('demand_id',$demandId);
  18. $grid->column('id');
  19. $grid->column('price','出价')->sortable();
  20. $grid->column('comment','内容');
  21. $grid->column('biddingUser.name','竞拍人');
  22. $grid->column('bidding','竞标')
  23. ->if(function () use ($demand){
  24. return $demand->state == 1;
  25. })
  26. ->then(function (Grid\Column $column) {
  27. $column->append(new ChooseDemand($this->id));
  28. })
  29. ->if(function () use ($demand){
  30. return $demand->state == 2;
  31. })
  32. ->then(function (Grid\Column $column) use ($demand){
  33. if ($demand->bidding_id == $this->id) {
  34. $column->append('<span class="text-success">已中标</span>');
  35. } else {
  36. $column->append('<span class="text-danger">未中标</span>');
  37. }
  38. });
  39. $grid->column('created_at');
  40. $grid->disableActions();
  41. $grid->disableRowSelector();
  42. });
  43. }
  44. }