mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -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\Exceptions\FireflyException;
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
use FireflyIII\Models\BudgetLimit;
|
use FireflyIII\Models\BudgetLimit;
|
||||||
|
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||||
use FireflyIII\Transformers\BudgetLimitTransformer;
|
use FireflyIII\Transformers\BudgetLimitTransformer;
|
||||||
@ -53,6 +54,10 @@ class BudgetLimitController extends Controller
|
|||||||
/** @var BudgetRepositoryInterface The budget repository */
|
/** @var BudgetRepositoryInterface The budget repository */
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
|
/** @var BudgetLimitRepositoryInterface */
|
||||||
|
private $blRepository;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BudgetLimitController constructor.
|
* BudgetLimitController constructor.
|
||||||
*
|
*
|
||||||
@ -66,7 +71,9 @@ class BudgetLimitController extends Controller
|
|||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$this->repository = app(BudgetRepositoryInterface::class);
|
$this->repository = app(BudgetRepositoryInterface::class);
|
||||||
|
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
|
||||||
$this->repository->setUser($user);
|
$this->repository->setUser($user);
|
||||||
|
$this->blRepository->setUser($user);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
@ -83,7 +90,7 @@ class BudgetLimitController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function delete(BudgetLimit $budgetLimit): JsonResponse
|
public function delete(BudgetLimit $budgetLimit): JsonResponse
|
||||||
{
|
{
|
||||||
$this->repository->destroyBudgetLimit($budgetLimit);
|
$this->blRepository->destroyBudgetLimit($budgetLimit);
|
||||||
|
|
||||||
return response()->json([], 204);
|
return response()->json([], 204);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Repositories\Budget;
|
namespace FireflyIII\Repositories\Budget;
|
||||||
|
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use FireflyIII\Models\BudgetLimit;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Log;
|
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
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Repositories\Budget;
|
namespace FireflyIII\Repositories\Budget;
|
||||||
|
|
||||||
|
use FireflyIII\Models\BudgetLimit;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,6 +31,13 @@ use FireflyIII\User;
|
|||||||
*/
|
*/
|
||||||
interface BudgetLimitRepositoryInterface
|
interface BudgetLimitRepositoryInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Destroy a budget limit.
|
||||||
|
*
|
||||||
|
* @param BudgetLimit $budgetLimit
|
||||||
|
*/
|
||||||
|
public function destroyBudgetLimit(BudgetLimit $budgetLimit): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*/
|
*/
|
||||||
|
@ -110,20 +110,6 @@ class BudgetRepository implements BudgetRepositoryInterface
|
|||||||
return true;
|
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 int|null $budgetId
|
||||||
* @param string|null $budgetName
|
* @param string|null $budgetName
|
||||||
|
@ -47,13 +47,6 @@ interface BudgetRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function destroy(Budget $budget): bool;
|
public function destroy(Budget $budget): bool;
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy a budget limit.
|
|
||||||
*
|
|
||||||
* @param BudgetLimit $budgetLimit
|
|
||||||
*/
|
|
||||||
public function destroyBudgetLimit(BudgetLimit $budgetLimit): void;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int|null $budgetId
|
* @param int|null $budgetId
|
||||||
* @param string|null $budgetName
|
* @param string|null $budgetName
|
||||||
@ -72,6 +65,8 @@ interface BudgetRepositoryInterface
|
|||||||
public function findByName(?string $name): ?Budget;
|
public function findByName(?string $name): ?Budget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO refactor to "find"
|
||||||
|
*
|
||||||
* @param int|null $budgetId
|
* @param int|null $budgetId
|
||||||
*
|
*
|
||||||
* @return Budget|null
|
* @return Budget|null
|
||||||
|
Loading…
Reference in New Issue
Block a user