Skip to content

Firefly III: a personal finances manager

Rewrote bill service provider

James Cole3aaf35605445
diff --git a/app/Providers/BillServiceProvider.php b/app/Providers/BillServiceProvider.php
index 7275348a8d..a07e8e37ff 100644
--- a/app/Providers/BillServiceProvider.php
+++ b/app/Providers/BillServiceProvider.php
@@ -14,7 +14,8 @@ declare(strict_types = 1);
namespace FireflyIII\Providers;
-use FireflyIII\Exceptions\FireflyException;
+use FireflyIII\Repositories\Bill\BillRepository;
+use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;
@@ -43,16 +44,16 @@ class BillServiceProvider extends ServiceProvider
public function register()
{
$this->app->bind(
- 'FireflyIII\Repositories\Bill\BillRepositoryInterface',
- function (Application $app, array $arguments) {
- if (!isset($arguments[0]) && $app->auth->check()) {
- return app('FireflyIII\Repositories\Bill\BillRepository', [auth()->user()]);
- }
- if (!isset($arguments[0]) && !$app->auth->check()) {
- throw new FireflyException('There is no user present.');
+ BillRepositoryInterface::class,
+ function (Application $app) {
+ /** @var BillRepositoryInterface $repository */
+ $repository = app(BillRepository::class);
+
+ if ($app->auth->check()) {
+ $repository->setUser(auth()->user());
}
- return app('FireflyIII\Repositories\Bill\BillRepository', $arguments);
+ return $repository;
}
);
}