'Update Booking Owner', 'message' => "You have successfully updated booking's owner" ]; } /** @var CanUpdateBooking */ private $canUpdateBooking; /** @var UpdatesBookingOwner */ private $updatesBookingOwner; /** @var FetchesBooking */ private $fetchesBooking; /** @var CanFetchBooking */ private $canFetchBooking; /** @var FetchesCompany */ private $fetchesCompany; /** * UpdateBookingLogic constructor. * @param CanUpdateBooking $canUpdateBooking * @param UpdatesBookingOwner $updatesBookingOwner * @param CanFetchBooking $canFetchBooking * @param FetchesBooking $fetchesBooking * @param FetchesCompany $fetchesCompany */ public function __construct( CanUpdateBooking $canUpdateBooking, UpdatesBookingOwner $updatesBookingOwner, CanFetchBooking $canFetchBooking, FetchesBooking $fetchesBooking, FetchesCompany $fetchesCompany ) { $this->canUpdateBooking = $canUpdateBooking; $this->updatesBookingOwner = $updatesBookingOwner; $this->canFetchBooking = $canFetchBooking; $this->fetchesBooking = $fetchesBooking; $this->fetchesCompany = $fetchesCompany; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request): JsonResponse { $this->canFetchBooking->passes(); $booking = $this->fetchesBooking->execute([ 'id' => $request->route('id'), ]); $newCompanyId = Company::where('reference', $request->input('newMarking'))->first()->id; $this->updatesBookingOwner->execute($booking, $newCompanyId); return $this->resourceResponse(new BookingResource($booking)); } }