Skip to content

Commit

Permalink
Make it possible to use custom invoice reference # (#15)
Browse files Browse the repository at this point in the history
* Update invoicable.php

* Update InvoicableServiceProvider.php

* Update Invoice.php

* Missing class

* Wrong definition in the config file

* No need to include the generator class
  • Loading branch information
rabol authored and sandervanhooft committed Mar 29, 2019
1 parent 5e7121b commit dd5b2c1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/invoicable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
'default_currency' => 'EUR',
'default_status' => 'concept',
'locale' => 'nl_NL',
];
'invoice_reference_generator' => SanderVanHooft\Invoicable\InvoiceReferenceGenerator::class
];
3 changes: 3 additions & 0 deletions src/InvoicableServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
}
1 change: 1 addition & 0 deletions tests/Feature/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use SanderVanHooft\Invoicable\Invoice;
use SanderVanHooft\Invoicable\TestModel;


class InvoiceTest extends AbstractTestCase
{
use DatabaseMigrations;
Expand Down

0 comments on commit dd5b2c1

Please sign in to comment.