Browse Source

增加product频道产品列表方法

dev
李可松 4 years ago
parent
commit
08e9afa317
  1. 16
      app/Http/Controllers/Api/ChannelController.php

16
app/Http/Controllers/Api/ChannelController.php

@ -2,8 +2,10 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\AgentProduct;
use App\Models\Channel; use App\Models\Channel;
use App\Models\UserChannel; use App\Models\UserChannel;
use Illuminate\Support\Facades\DB;
/** /**
* 频道列表 * 频道列表
@ -30,4 +32,18 @@ class ChannelController extends Controller
$list = Channel::whereIn('id', $channel_ids)->get(['id', 'pid', 'name', 'icon']); $list = Channel::whereIn('id', $channel_ids)->get(['id', 'pid', 'name', 'icon']);
return $this->success($list); return $this->success($list);
} }
//根据频道ID获取产品
public function product()
{
$channel_id = (int)request()->input('channel_id');
$list = AgentProduct::where('agent_id', $this->agent_id)
->whereRaw("FIND_IN_SET($channel_id, `channel_id`)")
->with('product:id,title,pictures')
->select('id', 'sale', 'product_id', 'price', 'original_price')
->orderBy('id', 'DESC')
->simplePaginate();
return $this->success($list);
}
} }
Loading…
Cancel
Save