Skip to content

Commit

Permalink
Only show enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
alecritson committed Feb 15, 2024
1 parent 5646969 commit 72b09d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/admin/src/Filament/Resources/DiscountResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected static function getMaxUsesPerUserFormComponent(): Component

protected static function getMinimumCartAmountsFormComponents(): array
{
$currencies = Currency::get();
$currencies = Currency::enabled()->get();
$inputs = [];

foreach ($currencies as $currency) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ protected function mutateFormDataBeforeSave(array $data): array
{
$minPrices = $data['data']['min_prices'] ?? [];
$fixedPrices = $data['data']['fixed_values'] ?? [];
$currencies = Currency::get();

$currencies = Currency::enabled()->get();
foreach ($minPrices as $currencyCode => $value) {
$currency = $currencies->first(
fn ($currency) => $currency->code == $currencyCode
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/Models/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ protected static function newFactory(): CurrencyFactory
return CurrencyFactory::new();
}

public function scopeEnabled($query, $enabled = true)
{
return $query->whereEnabled($enabled);
}

/**
* Return the prices relationship
*/
Expand Down

0 comments on commit 72b09d3

Please sign in to comment.