海南旅游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.

34 lines
913 B

4 years ago
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\AgentProduct;
  5. use App\Models\Special;
  6. use Illuminate\Support\Facades\Storage;
  7. class SpecialController extends Controller
  8. {
  9. //专题产品列表
  10. public function show()
  11. {
  12. $id = (int)request()->input('id');
  13. $prefix = Storage::disk('public')->url('');
  14. $detail = Special::query()
  15. ->select(['id', 'picture', 'updated_at', 'agent_product_id'])
  16. ->find($id);
  17. if ($detail->picture) {
  18. $detail->picture = array_map(fn($v) => $prefix . $v, $detail->picture);
  19. }
  20. $detail->product = AgentProduct::list($this->agent_id)
  21. ->whereIn('id', $detail->agent_product_id)
  22. ->orderBy('id', 'DESC')->limit(6)->get();
  23. foreach ($detail->product as $k => &$v) {
  24. $v->pictures = array_map(fn($item) => $prefix . $item, $v->pictures);
  25. }
  26. unset($detail->agent_product_id);
  27. return $this->success($detail);
  28. }
  29. }