mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Rewrote bill service provider
This commit is contained in:
parent
2c786e6a38
commit
3aaf356054
@ -14,7 +14,8 @@ declare(strict_types = 1);
|
|||||||
|
|
||||||
namespace FireflyIII\Providers;
|
namespace FireflyIII\Providers;
|
||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Repositories\Bill\BillRepository;
|
||||||
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
@ -43,16 +44,16 @@ class BillServiceProvider extends ServiceProvider
|
|||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
$this->app->bind(
|
$this->app->bind(
|
||||||
'FireflyIII\Repositories\Bill\BillRepositoryInterface',
|
BillRepositoryInterface::class,
|
||||||
function (Application $app, array $arguments) {
|
function (Application $app) {
|
||||||
if (!isset($arguments[0]) && $app->auth->check()) {
|
/** @var BillRepositoryInterface $repository */
|
||||||
return app('FireflyIII\Repositories\Bill\BillRepository', [auth()->user()]);
|
$repository = app(BillRepository::class);
|
||||||
}
|
|
||||||
if (!isset($arguments[0]) && !$app->auth->check()) {
|
if ($app->auth->check()) {
|
||||||
throw new FireflyException('There is no user present.');
|
$repository->setUser(auth()->user());
|
||||||
}
|
}
|
||||||
|
|
||||||
return app('FireflyIII\Repositories\Bill\BillRepository', $arguments);
|
return $repository;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user