12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace App\Modules\Mini\Controllers;
- use App\Base\BaseController;
- use App\Models\Order\Order;
- use App\Modules\Mini\Services\CartService;
- use App\Modules\Mini\Services\FavService;
- use App\Modules\Mini\Services\GoodsService;
- use App\Modules\Mini\Services\OrderService;
- 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 fav()
- {
- $params = $this->valid([
- "id" => "required",
- ]);
- return $this->ok([
- "was_created" => app(FavService::class)->fav(Auth::id(), $params)->wasRecentlyCreated,
- ]);
- }
- public function ask()
- {
- $params = $this->valid([
- "id" => "required",
- "custom" => "",
- "count" => "",
- ]);
- $params['source'] = Order::SOURCE_GOODS;
- return $this->ok(app(OrderService::class)->askOne(Auth::user(), $params));
- }
- public function cart()
- {
- $params = $this->valid([
- "id" => "required",
- 'count' => "required",
- "custom" => "",
- ]);
- $cart = app(CartService::class)->add(Auth::user(), $params);
- return $this->ok([
- "id" => $cart->id,
- ]);
- }
- }
|