<?php

namespace App\Modules\Room\Infrastructure;

use App\Modules\BookingExtra\Domain\IdBookingExtra;
use App\Modules\Room\Domain\IdRoom;
use App\Modules\Room\Domain\Room;
use App\Modules\Room\Domain\RoomRepository;
use App\Modules\Shared\Domain\Storage\Criteria\StorageCriteria;
use App\Modules\Shared\Infraestructure\DBRequester;
use Illuminate\Support\Facades\DB;

class MysqlRoomRepository implements RoomRepository
{

    public function copyRoom(
        IdRoom $room,
        IdBookingExtra $idBookingExtra,
        $idAdmin
    ) {
        $copyRoomQuery = new MysqlCopyRoomQuery($room, $idBookingExtra, $idAdmin);
        return $copyRoomQuery->__invoke($room, $idBookingExtra, $idAdmin);
    }

    public function find(StorageCriteria $criteria): Room
    {
        return $criteria->run();
    }

    public function search(StorageCriteria $criteria): array
    {
        return $criteria->run();
    }

    public function insert(Room $model): IdRoom
    {
        return new IdRoom(DBRequester::requestInsert($model));
    }

    public function update(Room $model)
    {
        return DBRequester::requestUpdate($model);
    }

    public function updatePartial(Room $model)
    {
        return DBRequester::requestUpdatePartial($model);
    }
}
