Skip to content

Commit

Permalink
Instantiate the class using the app method so that it's overwriteable
Browse files Browse the repository at this point in the history
  • Loading branch information
afonic committed Nov 13, 2024
1 parent 195a2ad commit d58d9cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Livewire/Traits/HandlesAvailabilityQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait HandlesAvailabilityQueries
public function getAvailability(Collection $data): array
{
try {
return (new Availability)->getAvailable($this->toResrvArray($data->first()));
return app(Availability::class)->getAvailable($this->toResrvArray($data->first()));
} catch (AvailabilityException $exception) {
return [
'message' => [
Expand All @@ -28,7 +28,7 @@ public function getAvailability(Collection $data): array
public function queryBaseAvailabilityForEntry(): array
{
try {
return (new Availability)->getAvailabilityForEntry($this->data->toResrvArray(), $this->entryId);
return app(Availability::class)->getAvailabilityForEntry($this->data->toResrvArray(), $this->entryId);
} catch (AvailabilityException $exception) {
$this->addError('availability', $exception->getMessage());

Expand All @@ -43,7 +43,7 @@ public function queryExtraAvailabilityForEntry(): Collection
$periods->transform(function ($period) {
$searchData = array_merge($period, Arr::only($this->data->toResrvArray(), ['quantity', 'advanced']));
try {
return (new Availability)->getAvailabilityForEntry($searchData, $this->entryId);
return app(Availability::class)->getAvailabilityForEntry($searchData, $this->entryId);
} catch (AvailabilityException $exception) {
return [
'message' => [
Expand All @@ -60,7 +60,7 @@ public function queryExtraAvailabilityForEntry(): Collection
public function validateAvailabilityAndPrice()
{
$searchData = array_merge(['price' => data_get($this->availability, 'data.price')], $this->data->toResrvArray());
if ((new Availability)->confirmAvailabilityAndPrice($searchData, $this->entryId) === false) {
if (app(Availability::class)->confirmAvailabilityAndPrice($searchData, $this->entryId) === false) {
throw new AvailabilityException(__('This item is not available anymore or the price has changed. Please refresh and try searching again!'));
}
}
Expand Down

0 comments on commit d58d9cd

Please sign in to comment.