<?php

namespace App\Modules\ShopperRequest\Controllers;

use App\Http\Controllers\Controller;
use App\Modules\ShopperRequest\Services\ShopperRequestService;
use App\Modules\ShopperRequest\Requests\UpdateShopperRequestRequest;
use App\Modules\ShopperRequest\DTOs\UpdateShopperRequestDTO;
use App\Models\ShopperRequest;

class ShopperRequestController extends Controller
{
    public function __construct(
        protected ShopperRequestService $service
    ) {}

    public function current()
    {
        return $this->service->current();
    }

    public function update(UpdateShopperRequestRequest $request, $id )
    {

        $dto = new UpdateShopperRequestDTO(

            $request->buy_from,

            $request->deliver_to,

            $request->deliver_latitude,

            $request->deliver_longitude,

            $request->remove_box_tags,

            $request->over_2kg,

            $request->includes_tobacco,

            $request->includes_liquids_or_medicines,

            $request->notes,
        );

        return $this->service->update($id, $dto);
    }

    public function publish($id)
    {
        return $this->service->publish($id);
    }


    /*
        |--------------------------------------------------------------------------
        | DELETE BASKET (Full Delete - حتى لو published)
        |--------------------------------------------------------------------------
    */
    public function destroy($id)
    {
        return $this->service->destroy($id);   // ← هذا هو الصح
    }

    public function index()
    {
        return $this->service->index();
    }
}