mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-30 10:47:06 -06:00
Move method to correct repository.
This commit is contained in:
parent
4cdbea2737
commit
e525960320
@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Requests\BudgetLimitRequest;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||
use FireflyIII\Transformers\BudgetLimitTransformer;
|
||||
@ -53,6 +54,10 @@ class BudgetLimitController extends Controller
|
||||
/** @var BudgetRepositoryInterface The budget repository */
|
||||
private $repository;
|
||||
|
||||
/** @var BudgetLimitRepositoryInterface */
|
||||
private $blRepository;
|
||||
|
||||
|
||||
/**
|
||||
* BudgetLimitController constructor.
|
||||
*
|
||||
@ -66,7 +71,9 @@ class BudgetLimitController extends Controller
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$this->repository = app(BudgetRepositoryInterface::class);
|
||||
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||
$this->repository->setUser($user);
|
||||
$this->blRepository->setUser($user);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@ -83,7 +90,7 @@ class BudgetLimitController extends Controller
|
||||
*/
|
||||
public function delete(BudgetLimit $budgetLimit): JsonResponse
|
||||
{
|
||||
$this->repository->destroyBudgetLimit($budgetLimit);
|
||||
$this->blRepository->destroyBudgetLimit($budgetLimit);
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Repositories\Budget;
|
||||
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\User;
|
||||
use Log;
|
||||
|
||||
@ -47,6 +49,20 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a budget limit.
|
||||
*
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*/
|
||||
public function destroyBudgetLimit(BudgetLimit $budgetLimit): void
|
||||
{
|
||||
try {
|
||||
$budgetLimit->delete();
|
||||
} catch (Exception $e) {
|
||||
Log::info(sprintf('Could not delete budget limit: %s', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Repositories\Budget;
|
||||
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\User;
|
||||
|
||||
/**
|
||||
@ -30,6 +31,13 @@ use FireflyIII\User;
|
||||
*/
|
||||
interface BudgetLimitRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Destroy a budget limit.
|
||||
*
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*/
|
||||
public function destroyBudgetLimit(BudgetLimit $budgetLimit): void;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
|
@ -110,20 +110,6 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a budget limit.
|
||||
*
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*/
|
||||
public function destroyBudgetLimit(BudgetLimit $budgetLimit): void
|
||||
{
|
||||
try {
|
||||
$budgetLimit->delete();
|
||||
} catch (Exception $e) {
|
||||
Log::info(sprintf('Could not delete budget limit: %s', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $budgetId
|
||||
* @param string|null $budgetName
|
||||
|
@ -47,13 +47,6 @@ interface BudgetRepositoryInterface
|
||||
*/
|
||||
public function destroy(Budget $budget): bool;
|
||||
|
||||
/**
|
||||
* Destroy a budget limit.
|
||||
*
|
||||
* @param BudgetLimit $budgetLimit
|
||||
*/
|
||||
public function destroyBudgetLimit(BudgetLimit $budgetLimit): void;
|
||||
|
||||
/**
|
||||
* @param int|null $budgetId
|
||||
* @param string|null $budgetName
|
||||
@ -72,6 +65,8 @@ interface BudgetRepositoryInterface
|
||||
public function findByName(?string $name): ?Budget;
|
||||
|
||||
/**
|
||||
* TODO refactor to "find"
|
||||
*
|
||||
* @param int|null $budgetId
|
||||
*
|
||||
* @return Budget|null
|
||||
|
Loading…
Reference in New Issue
Block a user