12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace App\Modules\Mini\Controllers;
- use App\Base\BaseController;
- use App\Modules\Mini\Services\FavService;
- use App\Modules\Mini\Services\GoodsService;
- use Faker\Provider\Image;
- use Illuminate\Support\Facades\Auth;
- class GoodsController extends BaseController
- {
- protected GoodsService $service;
- /**
- * @param GoodsService $service
- */
- public function __construct(GoodsService $service)
- {
- $this->service = $service;
- }
- public function goods()
- {
- $params = $this->valid([
- "id" => "required",
- ]);
- return $this->ok($this->service->info($params));
- }
- public function search()
- {
- return $this->ok([
- "total" => 1,
- "page_total" => 1,
- "list" => [
- [
- "id" => 1,
- "name" => "商品名称",
- "thumb" => Image::imageUrl(),
- ],
- ],
- "category" => [
- [
- "id" => 1,
- "thumb" => Image::imageUrl(),
- "name" => "分类名称",
- ],
- ],
- ]);
- }
- public function fav()
- {
- $params = $this->valid([
- "id" => "required",
- ]);
- return $this->ok([
- "was_created" => app(FavService::class)->fav(Auth::id(), $params)->wasRecentlyCreated,
- ]);
- }
- public function ask()
- {
- return $this->ok([
- "id" => 1,
- "thumb" => Image::imageUrl(),
- "name" => "商品名称",
- "url" => "http://baidu.com/xxxx",
- ]);
- }
- }
|