Skip to content

Commit

Permalink
Merge pull request #70 from pelmered/add-money-blueprint-for-migrations
Browse files Browse the repository at this point in the history
Add money blueprint for migrations
  • Loading branch information
pelmered authored Nov 7, 2024
2 parents 88d1991 + 04c9b7d commit b5fa1ed
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 8 deletions.
8 changes: 8 additions & 0 deletions src/FilamentMoneyFieldServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Pelmered\FilamentMoneyField;

use Illuminate\Database\Schema\Blueprint;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

Expand All @@ -20,5 +21,12 @@ public function boot(): void
$this->publishes([
__DIR__.'/../config/filament-money-field.php' => config_path('filament-money-field.php'),
], 'config');

Blueprint::macro('money', function (string $name, ?string $indexName = null) {
$this->unsignedBigInteger($name);
$this->string("{$name}_currency");

$this->index([$name, "{$name}_currency"], $indexName);
});
}
}
2 changes: 1 addition & 1 deletion src/Forms/Components/MoneyInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Pelmered\FilamentMoneyField\Concerns\HasMoneyAttributes;
use Pelmered\FilamentMoneyField\Forms\Rules\MaxValueRule;
use Pelmered\FilamentMoneyField\Forms\Rules\MinValueRule;
use Pelmered\FilamentMoneyField\MoneyFormatter;
use Pelmered\FilamentMoneyField\MoneyFormatter\MoneyFormatter;

class MoneyInput extends TextInput
{
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/Rules/MaxValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Money\Exception\ParserException;
use Pelmered\FilamentMoneyField\Concerns\FormatsAttributes;
use Pelmered\FilamentMoneyField\Forms\Components\MoneyInput;
use Pelmered\FilamentMoneyField\MoneyFormatter;
use Pelmered\FilamentMoneyField\MoneyFormatter\MoneyFormatter;

readonly class MaxValueRule implements ValidationRule
{
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/Rules/MinValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Money\Exception\ParserException;
use Pelmered\FilamentMoneyField\Concerns\FormatsAttributes;
use Pelmered\FilamentMoneyField\Forms\Components\MoneyInput;
use Pelmered\FilamentMoneyField\MoneyFormatter;
use Pelmered\FilamentMoneyField\MoneyFormatter\MoneyFormatter;

readonly class MinValueRule implements ValidationRule
{
Expand Down
2 changes: 1 addition & 1 deletion src/Infolists/Components/MoneyEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Filament\Infolists\Components\TextEntry;
use Pelmered\FilamentMoneyField\Concerns\HasMoneyAttributes;
use Pelmered\FilamentMoneyField\MoneyFormatter;
use Pelmered\FilamentMoneyField\MoneyFormatter\MoneyFormatter;

class MoneyEntry extends TextEntry
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Pelmered\FilamentMoneyField;
namespace Pelmered\FilamentMoneyField\MoneyFormatter;

use Illuminate\Support\Number;
use Money\Currencies\ISOCurrencies;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Pelmered\FilamentMoneyField;
namespace Pelmered\FilamentMoneyField\MoneyFormatter;

class MoneyFormattingRules
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tables/Columns/MoneyColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Filament\Tables\Columns\TextColumn;
use Pelmered\FilamentMoneyField\Concerns\HasMoneyAttributes;
use Pelmered\FilamentMoneyField\MoneyFormatter;
use Pelmered\FilamentMoneyField\MoneyFormatter\MoneyFormatter;

class MoneyColumn extends TextColumn
{
Expand Down
5 changes: 4 additions & 1 deletion tests/MoneyFormatterTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php

namespace Pelmered\FilamentMoneyField\Tests;

use Money\Currency;
use Pelmered\FilamentMoneyField\MoneyFormatter;
use Pelmered\FilamentMoneyField\Tests\TestCase;
use Pelmered\FilamentMoneyField\MoneyFormatter\MoneyFormatter;
use PHPUnit\Framework\Attributes\DataProvider;

uses(TestCase::class);

Expand Down

0 comments on commit b5fa1ed

Please sign in to comment.