Files
omair saleh 05401f6bbc large commit
2021-03-11 13:06:40 +08:00

61 lines
1.6 KiB
PHP

<?php
namespace App\Classes\Modules\Bookings\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Bookings\Services\FetchesBooking;
use App\Classes\Modules\Bookings\Standards\Rules\CanFetchBooking;
use App\Http\Resources\BookingResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class FetchBookingLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved Address',
'message' => 'You have successfully retrieved a Address'
];
}
/** @var CanFetchBooking */
private $canFetchBooking;
/** @var FetchesBooking */
private $fetchesBooking;
/**
* FetchBookingLogic constructor.
* @param CanFetchBooking $canFetchBooking
* @param FetchesBooking $fetchesBooking
*/
public function __construct(CanFetchBooking $canFetchBooking, FetchesBooking $fetchesBooking)
{
$this->canFetchBooking = $canFetchBooking;
$this->fetchesBooking = $fetchesBooking;
}
/**
* @param Request $request
* @return JsonResponse
* @throws \App\Classes\Exceptions\AccessForbiddenException
* @throws \App\Classes\Exceptions\RequestValidationException
*/
public function logic(Request $request) : JsonResponse
{
$this->canFetchBooking->passes();
$query = $this->fetchesBooking->execute(['marking' => $request->route('marking'), 'with_transactions' => true]);
return $this->resourceResponse(new BookingResource($query));
}
}