mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Various code reshuffelling.
This commit is contained in:
@@ -41,6 +41,14 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
{
|
||||
private User $user;
|
||||
|
||||
/**
|
||||
* Delete all available budgets.
|
||||
*/
|
||||
public function destroyAll(): void
|
||||
{
|
||||
$this->user->availableBudgets()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AvailableBudget $availableBudget
|
||||
*/
|
||||
@@ -171,6 +179,18 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getByCurrencyDate(Carbon $start, Carbon $end, TransactionCurrency $currency): ?AvailableBudget
|
||||
{
|
||||
return $this->user
|
||||
->availableBudgets()
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
->where('end_date', $end->format('Y-m-d'))->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $currency
|
||||
* @param Carbon $start
|
||||
@@ -215,13 +235,14 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
public function store(array $data): ?AvailableBudget
|
||||
{
|
||||
$start = $data['start'];
|
||||
if($start instanceof Carbon) {
|
||||
if ($start instanceof Carbon) {
|
||||
$start = $data['start']->startOfDay();
|
||||
}
|
||||
$end = $data['end'];
|
||||
if($end instanceof Carbon) {
|
||||
if ($end instanceof Carbon) {
|
||||
$end = $data['end']->endOfDay();
|
||||
}
|
||||
|
||||
return AvailableBudget::create(
|
||||
[
|
||||
'user_id' => $this->user->id,
|
||||
@@ -271,11 +292,11 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
}
|
||||
|
||||
$start = $data['start'];
|
||||
if($start instanceof Carbon) {
|
||||
if ($start instanceof Carbon) {
|
||||
$start = $data['start']->startOfDay();
|
||||
}
|
||||
$end = $data['end'];
|
||||
if($end instanceof Carbon) {
|
||||
if ($end instanceof Carbon) {
|
||||
$end = $data['end']->endOfDay();
|
||||
}
|
||||
|
||||
@@ -288,24 +309,4 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
return $availableBudget;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all available budgets.
|
||||
*/
|
||||
public function destroyAll(): void
|
||||
{
|
||||
$this->user->availableBudgets()->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getByCurrencyDate(Carbon $start, Carbon $end, TransactionCurrency $currency): ?AvailableBudget
|
||||
{
|
||||
return $this->user
|
||||
->availableBudgets()
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
->where('end_date', $end->format('Y-m-d'))->first();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user