Various code cleanup.

This commit is contained in:
James Cole
2021-04-06 08:51:27 +02:00
parent d32446b171
commit 5ceef2e9c3
47 changed files with 161 additions and 557 deletions

View File

@@ -94,13 +94,13 @@ class StoreController extends Controller
$validator = Validator::make(
['transactions' => [['description' => $e->getMessage()]]], ['transactions.0.description' => new IsDuplicateTransaction]
);
throw new ValidationException($validator);
throw new ValidationException($validator,0, $e);
} catch (FireflyException $e) {
Log::warning('Caught an exception. Return error message.');
Log::error($e->getMessage());
$message = sprintf('Internal exception: %s', $e->getMessage());
$validator = Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction]);
throw new ValidationException($validator);
throw new ValidationException($validator,0, $e);
}
app('preferences')->mark();
event(new StoredTransactionGroup($transactionGroup, $data['apply_rules'] ?? true));

View File

@@ -50,13 +50,9 @@ class DestroyController extends Controller
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
/** @var CurrencyRepositoryInterface repository */
$this->repository = app(CurrencyRepositoryInterface::class);
$this->userRepository = app(UserRepositoryInterface::class);
$this->repository->setUser($admin);
$this->repository->setUser(auth()->user());
return $next($request);
}

View File

@@ -77,13 +77,9 @@ class ListController extends Controller
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
/** @var CurrencyRepositoryInterface repository */
$this->repository = app(CurrencyRepositoryInterface::class);
$this->userRepository = app(UserRepositoryInterface::class);
$this->repository->setUser($admin);
$this->repository->setUser(auth()->user());
return $next($request);
}

View File

@@ -56,12 +56,8 @@ class ShowController extends Controller
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
/** @var CurrencyRepositoryInterface repository */
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser($admin);
$this->repository->setUser(auth()->user());
return $next($request);
}

View File

@@ -56,13 +56,9 @@ class StoreController extends Controller
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
/** @var CurrencyRepositoryInterface repository */
$this->repository = app(CurrencyRepositoryInterface::class);
$this->userRepository = app(UserRepositoryInterface::class);
$this->repository->setUser($admin);
$this->repository->setUser(auth()->user());
return $next($request);
}

View File

@@ -56,13 +56,9 @@ class UpdateController extends Controller
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
/** @var CurrencyRepositoryInterface repository */
$this->repository = app(CurrencyRepositoryInterface::class);
$this->userRepository = app(UserRepositoryInterface::class);
$this->repository->setUser($admin);
$this->repository->setUser(auth()->user());
return $next($request);
}