'Booking Locked', 'message' => 'You have successfully lock Booking from editing' ]; } /** @var CanCreateBooking */ private $canCreateBooking; /** @var FetchesBooking */ private $fetchesBooking; /** @var FetchesCompany */ private $fetchesCompany; /** @var CreatesKeyValuePair */ private $createsKeyValuePair; /** * CreateBookingLockLogic constructor. * @param CanCreateBooking $canCreateBooking * @param FetchesCompany $fetchesCompany * @param CreatesKeyValuePair $createsKeyValuePair * @param FetchesBooking $fetchesBooking */ public function __construct(CanCreateBooking $canCreateBooking, FetchesCompany $fetchesCompany, CreatesKeyValuePair $createsKeyValuePair, FetchesBooking $fetchesBooking) { $this->canCreateBooking = $canCreateBooking; $this->fetchesCompany = $fetchesCompany; $this->createsKeyValuePair = $createsKeyValuePair; $this->fetchesBooking = $fetchesBooking; } /** * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\AccessForbiddenException * @throws \App\Classes\Exceptions\MalformedRequestException * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { // cief todo: 110 - CanCreateBookingLock // $password = $request->input('password'); // if($password !== 'prototype'){ // throw new AccessForbiddenException('Incorrect Password'); // } $booking = $this->fetchesBooking->execute(['id' => $request->input('booking_id')]); $this->updateOrCreateKeyValuePair($booking, KVPKey::BOOKING_IS_LOCKED, 1); return $this->response([]); } private function updateOrCreateKeyValuePair($booking, $key, $value) { $booking->attributesKVP()->updateOrCreate( ['key' => $key], ['value' => $value] ); } }