mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code cleanup.
This commit is contained in:
@@ -23,9 +23,12 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Repositories\Currency;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||
use FireflyIII\Models\CurrencyExchangeRate;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Services\Internal\Destroy\CurrencyDestroyService;
|
||||
use FireflyIII\Services\Internal\Update\CurrencyUpdateService;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
@@ -89,8 +92,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO use service
|
||||
*
|
||||
* @param TransactionCurrency $currency
|
||||
*
|
||||
* @return bool
|
||||
@@ -98,7 +99,9 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
public function destroy(TransactionCurrency $currency): bool
|
||||
{
|
||||
if ($this->user->hasRole('owner')) {
|
||||
$currency->forceDelete();
|
||||
/** @var CurrencyDestroyService $service */
|
||||
$service = app(CurrencyDestroyService::class);
|
||||
$service->destroy($currency);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -307,30 +310,19 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO use factory
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return TransactionCurrency
|
||||
*/
|
||||
public function store(array $data): TransactionCurrency
|
||||
{
|
||||
/** @var TransactionCurrency $currency */
|
||||
$currency = TransactionCurrency::create(
|
||||
[
|
||||
'name' => $data['name'],
|
||||
'code' => $data['code'],
|
||||
'symbol' => $data['symbol'],
|
||||
'decimal_places' => $data['decimal_places'],
|
||||
]
|
||||
);
|
||||
/** @var TransactionCurrencyFactory $factory */
|
||||
$factory = app(TransactionCurrencyFactory::class);
|
||||
|
||||
return $currency;
|
||||
return $factory->create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO use factory
|
||||
*
|
||||
* @param TransactionCurrency $currency
|
||||
* @param array $data
|
||||
*
|
||||
@@ -338,12 +330,9 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
*/
|
||||
public function update(TransactionCurrency $currency, array $data): TransactionCurrency
|
||||
{
|
||||
$currency->code = $data['code'];
|
||||
$currency->symbol = $data['symbol'];
|
||||
$currency->name = $data['name'];
|
||||
$currency->decimal_places = $data['decimal_places'];
|
||||
$currency->save();
|
||||
/** @var CurrencyUpdateService $service */
|
||||
$service = app(CurrencyUpdateService::class);
|
||||
|
||||
return $currency;
|
||||
return $service->update($currency, $data);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user