Remove deprecated method.

This commit is contained in:
James Cole 2020-08-02 11:59:43 +02:00
parent fb0d31226a
commit e29b2066c2
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
3 changed files with 8 additions and 35 deletions

View File

@ -245,8 +245,7 @@ class BudgetLimitController extends Controller
public function update(BudgetLimitRequest $request, BudgetLimit $budgetLimit): JsonResponse
{
$data = $request->getAll();
$data['budget'] = $budgetLimit->budget;
$budgetLimit = $this->blRepository->updateBudgetLimit($budgetLimit, $data);
$budgetLimit = $this->blRepository->update($budgetLimit, $data);
$manager = $this->getManager();
/** @var BudgetLimitTransformer $transformer */

View File

@ -337,29 +337,11 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
*/
public function update(BudgetLimit $budgetLimit, array $data): BudgetLimit
{
$budgetLimit->amount = $data['amount'] ?? $budgetLimit->amount;
$budgetLimit->save();
return $budgetLimit;
}
/**
* @param BudgetLimit $budgetLimit
* @param array $data
*
* @return BudgetLimit
* @throws Exception
* @deprecated
*/
public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit
{
/** @var Budget $budget */
$budget = $data['budget'];
$budgetLimit->budget()->associate($budget);
$budgetLimit->start_date = $data['start']->format('Y-m-d 00:00:00');
$budgetLimit->end_date = $data['end']->format('Y-m-d 00:00:00');
$budgetLimit->amount = $data['amount'];
$budgetLimit->amount = $data['amount'] ?? $budgetLimit->amount;
$budgetLimit->budget_id = $data['budget_id'] ?? $budgetLimit->id;
$budgetLimit->budget_id = $data['budget'] ? $data['budget']->id : $budgetLimit->budget_id;
$budgetLimit->start_date = $data['start'] ? $data['start']->format('Y-m-d 00:00:00') : $budgetLimit->start_date;
$budgetLimit->end_date = $data['end'] ? $data['end']->format('Y-m-d 00:00:00') : $budgetLimit->end_date;
// if no currency has been provided, use the user's default currency:
/** @var TransactionCurrencyFactory $factory */
@ -370,9 +352,10 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface
}
$currency->enabled = true;
$currency->save();
$budgetLimit->transaction_currency_id = $currency->id;
$budgetLimit->transaction_currency_id = $currency->id;
$budgetLimit->save();
Log::debug(sprintf('Updated budget limit with ID #%d and amount %s', $budgetLimit->id, $data['amount']));
return $budgetLimit;

View File

@ -119,15 +119,6 @@ interface BudgetLimitRepositoryInterface
*/
public function update(BudgetLimit $budgetLimit, array $data): BudgetLimit;
/**
* @param BudgetLimit $budgetLimit
* @param array $data
*
* @return BudgetLimit
* @deprecated
*/
public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit;
/**
* @param Budget $budget
* @param Carbon $start