Skip to content

Commit

Permalink
Remove package
Browse files Browse the repository at this point in the history
  • Loading branch information
karlomikus committed Dec 15, 2024
1 parent bc06744 commit 2beb876
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 118 deletions.
2 changes: 1 addition & 1 deletion app/Http/Resources/PriceCategoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function toArray($request)
'name' => $this->name,
'description' => $this->description,
'currency' => $this->currency,
'currency_symbol' => $this->getCurrency()->getSymbol(),
'currency_symbol' => '', // TODO:...
];
}
}
2 changes: 1 addition & 1 deletion app/Models/Cocktail.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public function asJsonLDSchema(): array

public function calculatePrice(PriceCategory $priceCategory): Money
{
$totalPrice = Money::of(0, $priceCategory->getCurrency()->value)->toRational();
$totalPrice = Money::of(0, $priceCategory->getCurrency())->toRational();

/** @var CocktailIngredient */
foreach ($this->ingredients as $cocktailIngredient) {
Expand Down
6 changes: 3 additions & 3 deletions app/Models/PriceCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Kami\Cocktail\Models;

use Brick\Money\Currency;
use Illuminate\Database\Eloquent\Model;
use PrinsFrank\Standards\Currency\CurrencyAlpha3;
use Kami\Cocktail\Models\Concerns\HasBarAwareScope;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
Expand All @@ -18,9 +18,9 @@ class PriceCategory extends Model

public $timestamps = false;

public function getCurrency(): CurrencyAlpha3
public function getCurrency(): Currency
{
return CurrencyAlpha3::from($this->currency);
return Currency::of($this->currency);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/OpenAPI/Schemas/IngredientPriceRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function fromArray(array $source): self
$category = PriceCategory::findOrFail((int) $source['price_category_id']);
$price = Money::of(
$source['price'],
$category->getCurrency()->value,
$category->getCurrency(),
roundingMode: RoundingMode::UP
)->getMinorAmount()->toInt();

Expand Down
4 changes: 2 additions & 2 deletions app/Rules/ValidCurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Closure;
use Throwable;
use PrinsFrank\Standards\Currency\CurrencyAlpha3;
use Brick\Money\Currency;
use Illuminate\Contracts\Validation\ValidationRule;

class ValidCurrency implements ValidationRule
Expand All @@ -17,7 +17,7 @@ class ValidCurrency implements ValidationRule
public function validate(string $attribute, mixed $value, Closure $fail): void
{
try {
CurrencyAlpha3::from($value);
Currency::of($value);
} catch (Throwable) {
$fail('Currency must be in ISO 4217 (Alpha3) format');
}
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"laravel/scout": "^10.4",
"league/csv": "^9.0",
"meilisearch/meilisearch-php": "^1.0",
"prinsfrank/standards": "^3.9",
"spatie/array-to-xml": "^3.1",
"spatie/laravel-query-builder": "^5.2",
"spatie/laravel-sluggable": "^3.4",
Expand Down
107 changes: 1 addition & 106 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/Feature/Http/PriceCategoryControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function test_show_price_category_response(): void
->where('data.name', $cat->name)
->where('data.description', $cat->description)
->where('data.currency', $cat->currency)
->where('data.currency_symbol', '')
->where('data.currency_symbol', '')
->etc()
);
}
Expand All @@ -79,7 +79,7 @@ public function test_create_price_category_response(): void
->where('data.name', 'Test cat')
->where('data.description', 'Test cat desc')
->where('data.currency', 'USD')
->where('data.currency_symbol', '$')
->where('data.currency_symbol', '')
->etc()
);
}
Expand All @@ -103,7 +103,7 @@ public function test_update_price_category_response(): void
->where('data.name', 'Test cat')
->where('data.description', 'Test cat desc')
->where('data.currency', 'JPY')
->where('data.currency_symbol', '¥')
->where('data.currency_symbol', '')
->etc()
);
}
Expand Down

0 comments on commit 2beb876

Please sign in to comment.