BoxRecordRetrieveAttiresTable.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Admin\Renderable;
  3. use Dcat\Admin\Support\LazyRenderable;
  4. use Dcat\Admin\Widgets\Table;
  5. class BoxRecordRetrieveAttiresTable extends LazyRenderable
  6. {
  7. //
  8. public function render() {
  9. // 获取ID
  10. $ids = explode(",",$this->ids);
  11. $tmp = \App\Models\GiftBox::withTrashed()
  12. ->whereIn('id', $ids)
  13. ->with(['attire'])
  14. ->get()
  15. ->toArray();
  16. //
  17. $tmp = array_column($tmp, null, 'id');
  18. //
  19. $data = [];
  20. foreach($ids as $id) {
  21. $t = [
  22. 'id' => $tmp[$id]['attire_id'],
  23. 'name' => $tmp[$id]['attire']['name'],
  24. 'level' => $tmp[$id]['attire']['level'],
  25. 'img_1' => "<img src='".\Storage::disk('cosv5')->url($tmp[$id]['attire']["img_1"])."' style='width:60px;height:auto;'/>",
  26. 'img_2' => "<img src='".\Storage::disk('cosv5')->url($tmp[$id]['attire']["img_2"])."' style='width:60px;height:auto;'/>",
  27. 'cate' => $tmp[$id]['attire']['cate'],
  28. ];
  29. $data[] = $t;
  30. }
  31. //
  32. $titles = [
  33. '装扮ID',
  34. '名称',
  35. '级别',
  36. '正面图片',
  37. '背面图片',
  38. '类别',
  39. ];
  40. return Table::make($titles, $data);
  41. }
  42. }