Change currency from settings #671 (#672)

This commit is contained in:
Nabeel S
2020-04-26 11:55:20 -04:00
committed by GitHub
parent 03cfc648b0
commit 99f4f3b3d8
15 changed files with 63 additions and 29 deletions

View File

@@ -4,12 +4,23 @@ namespace App\Http\Controllers\Admin;
use App\Contracts\Controller;
use App\Models\Setting;
use App\Services\FinanceService;
use Igaster\LaravelTheme\Facades\Theme;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class SettingsController extends Controller
{
private $financeSvc;
/**
* @param FinanceService $financeSvc
*/
public function __construct(FinanceService $financeSvc)
{
$this->financeSvc = $financeSvc;
}
/**
* Get a list of themes formatted for a select box
*
@@ -30,6 +41,22 @@ class SettingsController extends Controller
return $theme_list;
}
/**
* Return the currency list
*
* @return array
*/
private function getCurrencyList(): array
{
$curr = [];
foreach (config('money') as $currency => $attrs) {
$name = $attrs['name'].' ('.$attrs['symbol'].'/'.$currency.')';
$curr[$currency] = $name;
}
return $curr;
}
/**
* Display the settings. Group them by the setting group
*/
@@ -39,6 +66,7 @@ class SettingsController extends Controller
$settings = $settings->groupBy('group');
return view('admin.settings.index', [
'currencies' => $this->getCurrencyList(),
'grouped_settings' => $settings,
'themes' => $this->getThemes(),
]);
@@ -68,6 +96,8 @@ class SettingsController extends Controller
$setting->save();
}
$this->financeSvc->changeJournalCurrencies();
flash('Settings saved!');
return redirect('/admin/settings');