diff --git a/config/invoicable.php b/config/invoicable.php index 88e27e9..63552fd 100644 --- a/config/invoicable.php +++ b/config/invoicable.php @@ -4,4 +4,5 @@ 'default_currency' => 'EUR', 'default_status' => 'concept', 'locale' => 'nl_NL', -]; \ No newline at end of file + 'invoice_reference_generator' => SanderVanHooft\Invoicable\InvoiceReferenceGenerator::class +]; diff --git a/src/InvoicableServiceProvider.php b/src/InvoicableServiceProvider.php index 70e1b23..021ccb4 100644 --- a/src/InvoicableServiceProvider.php +++ b/src/InvoicableServiceProvider.php @@ -30,6 +30,9 @@ public function boot() __DIR__.'/../database/migrations/2017_06_17_163005_create_invoices_tables.php' => database_path('migrations/2017_06_17_163005_create_invoices_tables.php'), ], 'migrations'); + + $config = $this->app->config['invoicable']; + $this->app->bind(InvoiceReferenceGenerator::class, $config['invoice_reference_generator']); } /** diff --git a/src/Invoice.php b/src/Invoice.php index 3cb3997..8af946f 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -147,7 +147,7 @@ protected static function boot() static::creating(function ($model) { $model->currency = config('invoicable.default_currency', 'EUR'); $model->status = config('invoicable.default_status', 'concept'); - $model->reference = InvoiceReferenceGenerator::generate(); + $model->reference = app()->make(InvoiceReferenceGenerator::class)->generate(); }); } } diff --git a/tests/Feature/InvoiceTest.php b/tests/Feature/InvoiceTest.php index 75e3ea9..e29d456 100644 --- a/tests/Feature/InvoiceTest.php +++ b/tests/Feature/InvoiceTest.php @@ -7,6 +7,7 @@ use SanderVanHooft\Invoicable\Invoice; use SanderVanHooft\Invoicable\TestModel; + class InvoiceTest extends AbstractTestCase { use DatabaseMigrations;