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;
|
||||
|
||||
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;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user