Browse Source

增加SpecialController

dev
李可松 4 years ago
parent
commit
d7a5d5e6db
  1. 28
      app/Http/Controllers/Api/SpecialController.php

28
app/Http/Controllers/Api/SpecialController.php

@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\AgentProduct;
use App\Models\Special;
use Illuminate\Http\Request;
class SpecialController extends Controller
{
//专题产品列表
public function show()
{
$id = (int)request()->input('id');
$detail = Special::query()
->select(['id', 'picture', 'picture_ad', 'updated_at', 'agent_product_id'])
->find($id);
$detail->product = AgentProduct::query()
->whereIn('id', $detail->agent_product_id)
->select('id', 'sale', 'product_id', 'price', 'original_price')
->with('product:id,title,pictures')
->limit(6)->get();
unset($detail->agent_product_id);
return $this->success($detail);
}
}
Loading…
Cancel
Save