<?php

namespace App\Http\Controllers;

use App\Http\Requests\IntakeCartRequest;
use App\Services\IntakeCartService;
use App\Traits\HasResponse;
use Illuminate\Http\Request;

class IntakeCartController extends Controller
{
    use HasResponse;

    /** @var IntakeCartService */
    private $intakeCartService;

    public function __construct(IntakeCartService $intakeCartService)
    {
        $this->intakeCartService = $intakeCartService;
    }

    public function list(Request $request)
    {
        $withPagination = $this->validatePagination($request->only('perPage', 'page'));
        return $this->intakeCartService->list($request->all(), $withPagination);
    }

    public function register(IntakeCartRequest $request)
    {
        return $this->intakeCartService->register($request->validated());
    }

    public function updateQuantity($id, Request $request)
    {
        return $this->intakeCartService->updateQuantity($id, $request->all());
    }

    public function deleteProduct($id)
    {
        return $this->intakeCartService->deleteProduct($id);
    }
}
