<?php

namespace App\Classes\Modules\Bookings\Services;

use App\Classes\General\Eloquent\AbstractUpdateMultipleRecord;
use App\Models\Booking;
use App\Models\Transaction;
use App\Models\TransactionDetail;

class UpdatesBookingTransaction extends AbstractUpdateMultipleRecord
{
    /**
     * @param int $booking_id
     * @param array $booking_values
     * @param array $transaction_ids
     * @param array $transaction_values
     * @param array $transaction_detail_ids
     * @param array $transaction_detail_values
     * @return mixed
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(int $booking_id, array $booking_values, array $transaction_ids, array $transaction_values, array $transaction_detail_ids, array $transaction_detail_values) {

        $booking_update_success = $this->handler(Booking::query(),[$booking_id],$booking_values);
        if($booking_update_success) {
            $booking_update_success = $this->handler(Transaction::query(), $transaction_ids, $transaction_values);
            $booking_update_success = $this->handler(TransactionDetail::query(), $transaction_detail_ids, $transaction_detail_values);
        }

        return $booking_update_success;
    }
}