Skip to content

Commit

Permalink
Merge pull request #262 from HendrikPrinsZA/bump/2023-09-13
Browse files Browse the repository at this point in the history
Updated dependencies
  • Loading branch information
HendrikPrinsZA authored Sep 13, 2023
2 parents 97f127b + 8d55c62 commit ddcc36c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17,483 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Setup node
Expand Down
24 changes: 5 additions & 19 deletions app/Enums/CountryCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace App\Enums;

use App\Collections\CurrencyCollection;
use App\Models\Currency;
use App\Traits\EnumTrait;
use Exception;

enum CountryCode: string
{
Expand All @@ -17,45 +15,33 @@ enum CountryCode: string
case US = 'US';
case ZA = 'ZA';

protected function getCurrencies(): CurrencyCollection
{
$currencies = Currency::all();
if ($currencies->isEmpty()) {
throw new Exception(sprintf('No currencies found for "%s"', $this->name));
}

return $currencies;
}

public function details(): array
{
$currencies = $this->getCurrencies();

return match ($this) {
self::AE => [
'code' => $this->value,
'name' => 'Dubai',
'currency_id' => $currencies->firstWhere('code', CurrencyCode::AED)->id,
'currency_id' => Currency::firstWhere('code', CurrencyCode::AED)?->id,
],
self::NL => [
'code' => $this->value,
'name' => 'The Netherlands',
'currency_id' => $currencies->firstWhere('code', CurrencyCode::EUR)->id,
'currency_id' => Currency::firstWhere('code', CurrencyCode::EUR)?->id,
],
self::UK => [
'code' => $this->value,
'name' => 'United Kingdom',
'currency_id' => $currencies->firstWhere('code', CurrencyCode::GBP)->id,
'currency_id' => Currency::firstWhere('code', CurrencyCode::GBP)?->id,
],
self::US => [
'code' => $this->value,
'name' => 'United States',
'currency_id' => $currencies->firstWhere('code', CurrencyCode::USD)->id,
'currency_id' => Currency::firstWhere('code', CurrencyCode::USD)?->id,
],
self::ZA => [
'code' => $this->value,
'name' => 'South Africa',
'currency_id' => $currencies->firstWhere('code', CurrencyCode::ZAR)->id,
'currency_id' => Currency::firstWhere('code', CurrencyCode::ZAR)?->id,
],
};
}
Expand Down
Loading

0 comments on commit ddcc36c

Please sign in to comment.