mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-20 21:13:59 +00:00
51 lines
1.0 KiB
PHP
51 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Bookings\Services;
|
|
|
|
|
|
use App\Classes\Exceptions\ResourceNotFoundException;
|
|
use App\Classes\General\Eloquent\AbstractGetRecord;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use App\Models\Booking;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
|
|
class GetBookings extends AbstractGetRecord
|
|
{
|
|
|
|
/** @var Booking */
|
|
private $repository;
|
|
|
|
/**
|
|
* FetchesUser constructor.
|
|
* @param Booking $repository
|
|
*/
|
|
public function __construct(Booking $repository)
|
|
{
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
|
|
/**
|
|
* @return Builder
|
|
*/
|
|
public function getRepository(): Builder
|
|
{
|
|
return $this->repository->newQuery();
|
|
}
|
|
|
|
/**
|
|
* @param Builder $query
|
|
* @return Collection
|
|
* @throws ResourceNotFoundException
|
|
*/
|
|
public function getResults(Builder $query):Collection
|
|
{
|
|
if (!$query->exists()) {
|
|
throw new ResourceNotFoundException('Unable to find any record based on the criteria provided');
|
|
}
|
|
|
|
return $query->get();
|
|
}
|
|
|
|
|
|
} |