From b5300e416c1e330e4dfa9fa60ff22abc5682c920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Thu, 6 Aug 2020 19:10:05 +0300 Subject: [PATCH] use fallback for default settings --- app/Http/Controllers/Common/Items.php | 2 +- app/Http/Controllers/Modals/Items.php | 2 +- app/Http/Controllers/Sales/Invoices.php | 2 +- app/Http/Controllers/Settings/Company.php | 11 +- app/Http/Controllers/Settings/Defaults.php | 8 - app/Http/Controllers/Settings/Email.php | 8 - app/Http/Controllers/Settings/Invoice.php | 8 - .../Controllers/Settings/Localisation.php | 8 - app/Http/Controllers/Settings/Schedule.php | 11 +- app/Traits/Currencies.php | 2 +- composer.json | 2 +- composer.lock | 176 +++++++++--------- config/setting.php | 57 ++++++ database/seeds/Settings.php | 57 ++---- database/seeds/TestCompany.php | 2 +- .../settings/invoice_template.blade.php | 4 +- .../views/settings/company/edit.blade.php | 12 +- .../views/settings/default/edit.blade.php | 16 +- resources/views/settings/email/edit.blade.php | 6 +- .../views/settings/invoice/edit.blade.php | 18 +- .../settings/localisation/edit.blade.php | 14 +- .../views/settings/schedule/edit.blade.php | 10 +- 22 files changed, 211 insertions(+), 225 deletions(-) diff --git a/app/Http/Controllers/Common/Items.php b/app/Http/Controllers/Common/Items.php index 36a47306a..6421effcf 100644 --- a/app/Http/Controllers/Common/Items.php +++ b/app/Http/Controllers/Common/Items.php @@ -54,7 +54,7 @@ class Items extends Controller $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); - $currency = Currency::where('code', setting('default.currency', 'USD'))->first(); + $currency = Currency::where('code', setting('default.currency'))->first(); return view('common.items.create', compact('categories', 'taxes', 'currency')); } diff --git a/app/Http/Controllers/Modals/Items.php b/app/Http/Controllers/Modals/Items.php index a60b4f318..0c5f50f46 100644 --- a/app/Http/Controllers/Modals/Items.php +++ b/app/Http/Controllers/Modals/Items.php @@ -34,7 +34,7 @@ class Items extends Controller $taxes = Tax::enabled()->orderBy('name')->get()->pluck('title', 'id'); - $currency = Currency::where('code', setting('default.currency', 'USD'))->first(); + $currency = Currency::where('code', setting('default.currency'))->first(); $html = view('modals.items.create', compact('categories', 'taxes', 'currency'))->render(); diff --git a/app/Http/Controllers/Sales/Invoices.php b/app/Http/Controllers/Sales/Invoices.php index bd2d6e131..059f3e16e 100644 --- a/app/Http/Controllers/Sales/Invoices.php +++ b/app/Http/Controllers/Sales/Invoices.php @@ -435,7 +435,7 @@ class Invoices extends Controller $currency = Currency::where('code', $currency_code)->first(); if (empty($currency)) { - $currency = Currency::where('code', setting('default.currency', 'USD'))->first(); + $currency = Currency::where('code', setting('default.currency'))->first(); } if ($currency) { diff --git a/app/Http/Controllers/Settings/Company.php b/app/Http/Controllers/Settings/Company.php index 7bc35145d..e97f6079c 100644 --- a/app/Http/Controllers/Settings/Company.php +++ b/app/Http/Controllers/Settings/Company.php @@ -3,20 +3,11 @@ namespace App\Http\Controllers\Settings; use App\Abstracts\Http\Controller; -use App\Models\Setting\Setting; class Company extends Controller { public function edit() { - $setting = Setting::prefix('company')->get()->transform(function ($s) { - $s->key = str_replace('company.', '', $s->key); - - return $s; - })->pluck('value', 'key'); - - return view('settings.company.edit', compact( - 'setting' - )); + return view('settings.company.edit'); } } diff --git a/app/Http/Controllers/Settings/Defaults.php b/app/Http/Controllers/Settings/Defaults.php index 476c8a155..6be3afb9e 100644 --- a/app/Http/Controllers/Settings/Defaults.php +++ b/app/Http/Controllers/Settings/Defaults.php @@ -5,7 +5,6 @@ namespace App\Http\Controllers\Settings; use App\Abstracts\Http\Controller; use App\Models\Banking\Account; use App\Models\Setting\Currency; -use App\Models\Setting\Setting; use App\Models\Setting\Tax; use App\Utilities\Modules; @@ -13,12 +12,6 @@ class Defaults extends Controller { public function edit() { - $setting = Setting::prefix('default')->get()->transform(function ($s) { - $s->key = str_replace('default.', '', $s->key); - - return $s; - })->pluck('value', 'key'); - $accounts = Account::enabled()->orderBy('name')->pluck('name', 'id'); $currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code'); @@ -28,7 +21,6 @@ class Defaults extends Controller $payment_methods = Modules::getPaymentMethods(); return view('settings.default.edit', compact( - 'setting', 'accounts', 'currencies', 'taxes', diff --git a/app/Http/Controllers/Settings/Email.php b/app/Http/Controllers/Settings/Email.php index 8b92b4b00..1f8e54f3c 100644 --- a/app/Http/Controllers/Settings/Email.php +++ b/app/Http/Controllers/Settings/Email.php @@ -6,7 +6,6 @@ use App\Abstracts\Http\Controller; use App\Http\Requests\Setting\Setting as Request; use App\Models\Common\Company; use App\Models\Common\EmailTemplate; -use App\Models\Setting\Setting; use App\Utilities\Installer; use Illuminate\Support\Str; @@ -33,12 +32,6 @@ class Email extends Controller public function edit() { - $setting = Setting::prefix('email')->get()->transform(function ($s) { - $s->key = str_replace('email.', '', $s->key); - - return $s; - })->pluck('value', 'key'); - $templates = EmailTemplate::all(); $email_protocols = [ @@ -49,7 +42,6 @@ class Email extends Controller ]; return view('settings.email.edit', compact( - 'setting', 'templates', 'email_protocols' )); diff --git a/app/Http/Controllers/Settings/Invoice.php b/app/Http/Controllers/Settings/Invoice.php index 4b58c69e0..387bd17e3 100644 --- a/app/Http/Controllers/Settings/Invoice.php +++ b/app/Http/Controllers/Settings/Invoice.php @@ -3,18 +3,11 @@ namespace App\Http\Controllers\Settings; use App\Abstracts\Http\Controller; -use App\Models\Setting\Setting; class Invoice extends Controller { public function edit() { - $setting = Setting::prefix('invoice')->get()->transform(function ($s) { - $s->key = str_replace('invoice.', '', $s->key); - - return $s; - })->pluck('value', 'key'); - $item_names = [ 'settings.invoice.item' => trans('settings.invoice.item'), 'settings.invoice.product' => trans('settings.invoice.product'), @@ -43,7 +36,6 @@ class Invoice extends Controller ]; return view('settings.invoice.edit', compact( - 'setting', 'item_names', 'price_names', 'quantity_names', diff --git a/app/Http/Controllers/Settings/Localisation.php b/app/Http/Controllers/Settings/Localisation.php index fc7200491..6f4b1f709 100644 --- a/app/Http/Controllers/Settings/Localisation.php +++ b/app/Http/Controllers/Settings/Localisation.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Settings; use App\Abstracts\Http\Controller; -use App\Models\Setting\Setting; use App\Traits\DateTime; class Localisation extends Controller @@ -12,12 +11,6 @@ class Localisation extends Controller public function edit() { - $setting = Setting::prefix('localisation')->get()->transform(function ($s) { - $s->key = str_replace('localisation.', '', $s->key); - - return $s; - })->pluck('value', 'key'); - $timezones = $this->getTimezones(); $date_formats = [ @@ -49,7 +42,6 @@ class Localisation extends Controller ]; return view('settings.localisation.edit', compact( - 'setting', 'timezones', 'date_formats', 'date_separators', diff --git a/app/Http/Controllers/Settings/Schedule.php b/app/Http/Controllers/Settings/Schedule.php index 5905c8fe4..187644d27 100644 --- a/app/Http/Controllers/Settings/Schedule.php +++ b/app/Http/Controllers/Settings/Schedule.php @@ -3,20 +3,11 @@ namespace App\Http\Controllers\Settings; use App\Abstracts\Http\Controller; -use App\Models\Setting\Setting; class Schedule extends Controller { public function edit() { - $setting = Setting::prefix('schedule')->get()->transform(function ($s) { - $s->key = str_replace('schedule.', '', $s->key); - - return $s; - })->pluck('value', 'key'); - - return view('settings.schedule.edit', compact( - 'setting' - )); + return view('settings.schedule.edit'); } } diff --git a/app/Traits/Currencies.php b/app/Traits/Currencies.php index 7fda86161..b7b07c036 100644 --- a/app/Traits/Currencies.php +++ b/app/Traits/Currencies.php @@ -73,7 +73,7 @@ trait Currencies public function getDefaultCurrency() { - return !empty($this->default_currency_code) ? $this->default_currency_code : setting('default.currency', 'USD'); + return !empty($this->default_currency_code) ? $this->default_currency_code : setting('default.currency'); } public function setDefaultCurrency($code) diff --git a/composer.json b/composer.json index 27837692d..c16db87f3 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "akaunting/menu": "1.0.*", "akaunting/module": "1.0.*", "akaunting/money": "1.2.*", - "akaunting/setting": "1.1.*", + "akaunting/setting": "1.2.*", "akaunting/version": "1.0.*", "barryvdh/laravel-debugbar": "3.3.*", "barryvdh/laravel-dompdf": "0.*", diff --git a/composer.lock b/composer.lock index 2d7b478dc..16f983dda 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d5770340d17c7c145a2f78e3d22c25d8", + "content-hash": "bbdd9ace718fa625472523fd9e6982c9", "packages": [ { "name": "akaunting/firewall", @@ -323,16 +323,16 @@ }, { "name": "akaunting/setting", - "version": "1.1.2", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/akaunting/setting.git", - "reference": "194f8c60285f66835f70e0a8e87e1a66d989b111" + "reference": "87df3967ffaea8e01fdb6ce5f142bdb4584d0f9f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/akaunting/setting/zipball/194f8c60285f66835f70e0a8e87e1a66d989b111", - "reference": "194f8c60285f66835f70e0a8e87e1a66d989b111", + "url": "https://api.github.com/repos/akaunting/setting/zipball/87df3967ffaea8e01fdb6ce5f142bdb4584d0f9f", + "reference": "87df3967ffaea8e01fdb6ce5f142bdb4584d0f9f", "shasum": "" }, "require": { @@ -382,7 +382,7 @@ "laravel", "persistent" ], - "time": "2020-04-29T07:18:49+00:00" + "time": "2020-08-06T10:01:46+00:00" }, { "name": "akaunting/version", @@ -1012,16 +1012,16 @@ }, { "name": "composer/composer", - "version": "1.10.9", + "version": "1.10.10", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "83c3250093d5491600a822e176b107a945baf95a" + "reference": "32966a3b1d48bc01472a8321fd6472b44fad033a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/83c3250093d5491600a822e176b107a945baf95a", - "reference": "83c3250093d5491600a822e176b107a945baf95a", + "url": "https://api.github.com/repos/composer/composer/zipball/32966a3b1d48bc01472a8321fd6472b44fad033a", + "reference": "32966a3b1d48bc01472a8321fd6472b44fad033a", "shasum": "" }, "require": { @@ -1102,7 +1102,7 @@ "type": "tidelift" } ], - "time": "2020-07-16T10:57:00+00:00" + "time": "2020-08-03T09:35:19+00:00" }, { "name": "composer/semver", @@ -1681,16 +1681,16 @@ }, { "name": "doctrine/collections", - "version": "1.6.6", + "version": "1.6.7", "source": { "type": "git", "url": "https://github.com/doctrine/collections.git", - "reference": "5f0470363ff042d0057006ae7acabc5d7b5252d5" + "reference": "55f8b799269a1a472457bd1a41b4f379d4cfba4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/collections/zipball/5f0470363ff042d0057006ae7acabc5d7b5252d5", - "reference": "5f0470363ff042d0057006ae7acabc5d7b5252d5", + "url": "https://api.github.com/repos/doctrine/collections/zipball/55f8b799269a1a472457bd1a41b4f379d4cfba4a", + "reference": "55f8b799269a1a472457bd1a41b4f379d4cfba4a", "shasum": "" }, "require": { @@ -1742,21 +1742,7 @@ "iterators", "php" ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcollections", - "type": "tidelift" - } - ], - "time": "2020-06-22T19:14:02+00:00" + "time": "2020-07-27T17:53:49+00:00" }, { "name": "doctrine/dbal", @@ -1842,20 +1828,20 @@ }, { "name": "doctrine/event-manager", - "version": "1.1.0", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/doctrine/event-manager.git", - "reference": "629572819973f13486371cb611386eb17851e85c" + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/event-manager/zipball/629572819973f13486371cb611386eb17851e85c", - "reference": "629572819973f13486371cb611386eb17851e85c", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f", + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "conflict": { "doctrine/common": "<2.9@dev" @@ -1914,7 +1900,21 @@ "event system", "events" ], - "time": "2019-11-10T09:48:07+00:00" + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager", + "type": "tidelift" + } + ], + "time": "2020-05-29T18:28:51+00:00" }, { "name": "doctrine/inflector", @@ -3306,16 +3306,16 @@ }, { "name": "laravel/framework", - "version": "v7.22.1", + "version": "v7.23.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "efc1fdb01016224a29fc8732be7464829e9273d7" + "reference": "17cbce101f2fc78e61a6135861823563c7cfb50b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/efc1fdb01016224a29fc8732be7464829e9273d7", - "reference": "efc1fdb01016224a29fc8732be7464829e9273d7", + "url": "https://api.github.com/repos/laravel/framework/zipball/17cbce101f2fc78e61a6135861823563c7cfb50b", + "reference": "17cbce101f2fc78e61a6135861823563c7cfb50b", "shasum": "" }, "require": { @@ -3459,7 +3459,7 @@ "framework", "laravel" ], - "time": "2020-07-27T15:05:08+00:00" + "time": "2020-08-04T14:36:37+00:00" }, { "name": "laravel/tinker", @@ -3997,16 +3997,16 @@ }, { "name": "maatwebsite/excel", - "version": "3.1.20", + "version": "3.1.21", "source": { "type": "git", "url": "https://github.com/Maatwebsite/Laravel-Excel.git", - "reference": "39545fa96b84d5a90f702239659c49a5d7b1edea" + "reference": "405ff5f0dd014a0d5a1fdb8fd6f525a9a1ece3f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/39545fa96b84d5a90f702239659c49a5d7b1edea", - "reference": "39545fa96b84d5a90f702239659c49a5d7b1edea", + "url": "https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/405ff5f0dd014a0d5a1fdb8fd6f525a9a1ece3f6", + "reference": "405ff5f0dd014a0d5a1fdb8fd6f525a9a1ece3f6", "shasum": "" }, "require": { @@ -4068,7 +4068,7 @@ "type": "github" } ], - "time": "2020-07-17T20:39:28+00:00" + "time": "2020-08-06T09:25:20+00:00" }, { "name": "maennchen/zipstream-php", @@ -4644,16 +4644,16 @@ }, { "name": "monooso/unobserve", - "version": "v2.0.0", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/monooso/unobserve.git", - "reference": "93d5c974380b95783d3c2db015440a88d1d6b635" + "reference": "88c20c4dce6b16b02bc197b616826e99c2cdbe7c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/monooso/unobserve/zipball/93d5c974380b95783d3c2db015440a88d1d6b635", - "reference": "93d5c974380b95783d3c2db015440a88d1d6b635", + "url": "https://api.github.com/repos/monooso/unobserve/zipball/88c20c4dce6b16b02bc197b616826e99c2cdbe7c", + "reference": "88c20c4dce6b16b02bc197b616826e99c2cdbe7c", "shasum": "" }, "require": { @@ -4695,7 +4695,7 @@ "keywords": [ "laravel" ], - "time": "2020-03-13T10:33:22+00:00" + "time": "2020-08-05T11:28:54+00:00" }, { "name": "myclabs/php-enum", @@ -4745,16 +4745,16 @@ }, { "name": "nesbot/carbon", - "version": "2.36.1", + "version": "2.38.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "ee7378a36cc62952100e718bcc58be4c7210e55f" + "reference": "d8f6a6a91d1eb9304527b040500f61923e97674b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/ee7378a36cc62952100e718bcc58be4c7210e55f", - "reference": "ee7378a36cc62952100e718bcc58be4c7210e55f", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/d8f6a6a91d1eb9304527b040500f61923e97674b", + "reference": "d8f6a6a91d1eb9304527b040500f61923e97674b", "shasum": "" }, "require": { @@ -4769,7 +4769,7 @@ "kylekatarnls/multi-tester": "^2.0", "phpmd/phpmd": "^2.8", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12.30", + "phpstan/phpstan": "^0.12.35", "phpunit/phpunit": "^7.5 || ^8.0", "squizlabs/php_codesniffer": "^3.4" }, @@ -4830,7 +4830,7 @@ "type": "tidelift" } ], - "time": "2020-07-04T12:29:56+00:00" + "time": "2020-08-04T19:12:46+00:00" }, { "name": "nikic/php-parser", @@ -6452,16 +6452,16 @@ }, { "name": "ramsey/uuid", - "version": "4.0.1", + "version": "4.1.0", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "ba8fff1d3abb8bb4d35a135ed22a31c6ef3ede3d" + "reference": "988dbefc7878d0a35f12afb4df1f7dd0bd153c43" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/ba8fff1d3abb8bb4d35a135ed22a31c6ef3ede3d", - "reference": "ba8fff1d3abb8bb4d35a135ed22a31c6ef3ede3d", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/988dbefc7878d0a35f12afb4df1f7dd0bd153c43", + "reference": "988dbefc7878d0a35f12afb4df1f7dd0bd153c43", "shasum": "" }, "require": { @@ -6476,7 +6476,7 @@ }, "require-dev": { "codeception/aspect-mock": "^3", - "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2", + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7.0", "doctrine/annotations": "^1.8", "goaop/framework": "^2", "mockery/mockery": "^1.3", @@ -6485,8 +6485,8 @@ "php-mock/php-mock-mockery": "^1.3", "php-mock/php-mock-phpunit": "^2.5", "php-parallel-lint/php-parallel-lint": "^1.1", + "phpbench/phpbench": "^0.17.1", "phpstan/extension-installer": "^1.0", - "phpstan/phpdoc-parser": "0.4.3", "phpstan/phpstan": "^0.12", "phpstan/phpstan-mockery": "^0.12", "phpstan/phpstan-phpunit": "^0.12", @@ -6529,7 +6529,13 @@ "identifier", "uuid" ], - "time": "2020-03-29T20:13:32+00:00" + "funding": [ + { + "url": "https://github.com/ramsey", + "type": "github" + } + ], + "time": "2020-07-28T16:51:01+00:00" }, { "name": "riverskies/laravel-mobile-detect", @@ -7927,7 +7933,7 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -8003,7 +8009,7 @@ }, { "name": "symfony/polyfill-iconv", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-iconv.git", @@ -8080,7 +8086,7 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", @@ -8158,16 +8164,16 @@ }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "bc6549d068d0160e0f10f7a5a23c7d1406b95ebe" + "reference": "5dcab1bc7146cf8c1beaa4502a3d9be344334251" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/bc6549d068d0160e0f10f7a5a23c7d1406b95ebe", - "reference": "bc6549d068d0160e0f10f7a5a23c7d1406b95ebe", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/5dcab1bc7146cf8c1beaa4502a3d9be344334251", + "reference": "5dcab1bc7146cf8c1beaa4502a3d9be344334251", "shasum": "" }, "require": { @@ -8239,11 +8245,11 @@ "type": "tidelift" } ], - "time": "2020-07-14T12:35:20+00:00" + "time": "2020-08-04T06:02:08+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -8324,7 +8330,7 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", @@ -8401,7 +8407,7 @@ }, { "name": "symfony/polyfill-php56", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php56.git", @@ -8475,7 +8481,7 @@ }, { "name": "symfony/polyfill-php70", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", @@ -8552,7 +8558,7 @@ }, { "name": "symfony/polyfill-php72", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", @@ -8625,7 +8631,7 @@ }, { "name": "symfony/polyfill-php73", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", @@ -8701,7 +8707,7 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", @@ -8781,7 +8787,7 @@ }, { "name": "symfony/polyfill-util", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-util.git", @@ -9862,16 +9868,16 @@ }, { "name": "facade/ignition", - "version": "2.3.4", + "version": "2.3.5", "source": { "type": "git", "url": "https://github.com/facade/ignition.git", - "reference": "87335b120bc9652e4ee2bf285b7322a785211476" + "reference": "58dc4a8df3d41174c677a370b6779b694e4539e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facade/ignition/zipball/87335b120bc9652e4ee2bf285b7322a785211476", - "reference": "87335b120bc9652e4ee2bf285b7322a785211476", + "url": "https://api.github.com/repos/facade/ignition/zipball/58dc4a8df3d41174c677a370b6779b694e4539e7", + "reference": "58dc4a8df3d41174c677a370b6779b694e4539e7", "shasum": "" }, "require": { @@ -9930,7 +9936,7 @@ "laravel", "page" ], - "time": "2020-07-27T15:17:39+00:00" + "time": "2020-08-01T21:20:01+00:00" }, { "name": "facade/ignition-contracts", diff --git a/config/setting.php b/config/setting.php index ae4eb5f13..7fdfe0f3a 100644 --- a/config/setting.php +++ b/config/setting.php @@ -84,6 +84,62 @@ return [ ], + /* + |-------------------------------------------------------------------------- + | Fallback + |-------------------------------------------------------------------------- + | + | Define fallback settings to be used in case the default is null + | + | Sample: + | "currency" => "USD", + | + */ + 'fallback' => [ + 'localisation' => [ + 'financial_start' => env('SETTING_FALLBACK_LOCALISATION_FINANCIAL_START', '01-01'), + 'timezone' => env('SETTING_FALLBACK_LOCALISATION_TIMEZONE', 'Europe/London'), + 'date_format' => env('SETTING_FALLBACK_LOCALISATION_DATE_FORMAT', 'd M Y'), + 'date_separator' => env('SETTING_FALLBACK_LOCALISATION_DATE_SEPARATOR', 'space'), + 'percent_position' => env('SETTING_FALLBACK_LOCALISATION_PERCENT_POSITION', 'after'), + 'discount_location' => env('SETTING_FALLBACK_LOCALISATION_DISCOUNT_LOCATION', 'total'), + ], + 'invoice' => [ + 'number_prefix' => env('SETTING_FALLBACK_INVOICE_NUMBER_PREFIX', 'INV-'), + 'number_digit' => env('SETTING_FALLBACK_INVOICE_NUMBER_DIGIT', '5'), + 'number_next' => env('SETTING_FALLBACK_INVOICE_NUMBER_NEXT', '1'), + 'item_name' => env('SETTING_FALLBACK_INVOICE_ITEM_NAME', 'settings.invoice.item'), + 'price_name' => env('SETTING_FALLBACK_INVOICE_PRICE_NAME', 'settings.invoice.price'), + 'quantity_name' => env('SETTING_FALLBACK_INVOICE_QUANTITY_NAME', 'settings.invoice.quantity'), + 'payment_terms' => env('SETTING_FALLBACK_INVOICE_PAYMENT_TERMS', '0'), + 'template' => env('SETTING_FALLBACK_INVOICE_TEMPLATE', 'default'), + 'color' => env('SETTING_FALLBACK_INVOICE_COLOR', '#55588b'), + ], + 'default' => [ + 'currency' => env('SETTING_FALLBACK_DEFAULT_CURRENCY', 'USD'), + 'locale' => env('SETTING_FALLBACK_DEFAULT_LOCALE', 'en-GB'), + 'list_limit' => env('SETTING_FALLBACK_DEFAULT_LIST_LIMIT', '25'), + 'payment_method' => env('SETTING_FALLBACK_DEFAULT_PAYMENT_METHOD', 'offline-payments.cash.1'), + ], + 'email' => [ + 'protocol' => env('SETTING_FALLBACK_EMAIL_PROTOCOL', 'mail'), + 'sendmail_path' => env('SETTING_FALLBACK_EMAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs'), + ], + 'schedule' => [ + 'send_invoice_reminder' => env('SETTING_FALLBACK_SCHEDULE_SEND_INVOICE_REMINDER', '0'), + 'invoice_days' => env('SETTING_FALLBACK_SCHEDULE_INVOICE_DAYS', '1,3,5,10'), + 'send_bill_reminder' => env('SETTING_FALLBACK_SCHEDULE_SEND_BILL_REMINDER', '0'), + 'bill_days' => env('SETTING_FALLBACK_SCHEDULE_BILL_DAYS', '10,5,3,1'), + 'time' => env('SETTING_FALLBACK_SCHEDULE_TIME', '09:00'), + ], + 'contact' => [ + 'type' => [ + 'customer' => env('SETTING_FALLBACK_CONTACT_TYPE_CUSTOMER', 'customer'), + 'vendor' => env('SETTING_FALLBACK_CONTACT_TYPE_VENDOR', 'vendor'), + ], + ], + ], + /* |-------------------------------------------------------------------------- | Required Extra Columns @@ -99,4 +155,5 @@ return [ 'required_extra_columns' => [ 'company_id', ], + ]; diff --git a/database/seeds/Settings.php b/database/seeds/Settings.php index d12ef1230..2bf4bfb86 100644 --- a/database/seeds/Settings.php +++ b/database/seeds/Settings.php @@ -27,54 +27,27 @@ class Settings extends Seeder setting()->setExtraColumns(['company_id' => $company_id]); - $offline_payments = []; - - $offline_payments[] = [ - 'code' => 'offline-payments.cash.1', - 'name' => trans('demo.offline_payments.cash'), - 'customer' => '0', - 'order' => '1', - 'description' => null, - ]; - - $offline_payments[] = [ - 'code' => 'offline-payments.bank_transfer.2', - 'name' => trans('demo.offline_payments.bank'), - 'customer' => '0', - 'order' => '2', - 'description' => null, + $offline_payments = [ + [ + 'code' => 'offline-payments.cash.1', + 'name' => trans('demo.offline_payments.cash'), + 'customer' => '0', + 'order' => '1', + 'description' => null, + ], + [ + 'code' => 'offline-payments.bank_transfer.2', + 'name' => trans('demo.offline_payments.bank'), + 'customer' => '0', + 'order' => '2', + 'description' => null, + ], ]; setting()->set([ - 'localisation.financial_start' => now()->startOfYear()->format('d-m'), - 'localisation.timezone' => 'Europe/London', - 'localisation.date_format' => 'd M Y', - 'localisation.date_separator' => 'space', - 'localisation.percent_position' => 'after', - 'invoice.number_prefix' => 'INV-', - 'invoice.number_digit' => '5', - 'invoice.number_next' => '1', - 'invoice.item_name' => 'settings.invoice.item', - 'invoice.price_name' => 'settings.invoice.price', - 'invoice.quantity_name' => 'settings.invoice.quantity', 'invoice.title' => trans_choice('general.invoices', 1), - 'invoice.payment_terms' => '0', - 'invoice.template' => 'default', - 'invoice.color' => '#55588b', - 'default.payment_method' => 'offline-payments.cash.1', - 'default.list_limit' => '25', - 'default.use_gravatar' => '0', - 'email.protocol' => 'mail', - 'email.sendmail_path' => '/usr/sbin/sendmail -bs', - 'schedule.send_invoice_reminder' => '0', - 'schedule.invoice_days' => '1,3,5,10', - 'schedule.send_bill_reminder' => '0', - 'schedule.bill_days' => '10,5,3,1', - 'schedule.time' => '09:00', 'wizard.completed' => '0', 'offline-payments.methods' => json_encode($offline_payments), - 'contact.type.customer' => 'customer', - 'contact.type.vendor' => 'vendor', ]); } } diff --git a/database/seeds/TestCompany.php b/database/seeds/TestCompany.php index d2df1735b..e915c8163 100644 --- a/database/seeds/TestCompany.php +++ b/database/seeds/TestCompany.php @@ -79,7 +79,7 @@ class TestCompany extends Seeder 'type' => 'customer', 'name' => 'Test Customer', 'email' => 'customer@company.com', - 'currency_code' => setting('default.currency', 'USD'), + 'currency_code' => setting('default.currency'), 'password' => '123456', 'password_confirmation' => '123456', 'company_id' => session('company_id'), diff --git a/resources/views/modals/settings/invoice_template.blade.php b/resources/views/modals/settings/invoice_template.blade.php index 0ae1d8654..dd495bda2 100644 --- a/resources/views/modals/settings/invoice_template.blade.php +++ b/resources/views/modals/settings/invoice_template.blade.php @@ -52,14 +52,14 @@ - {!! Form::text('color', $setting['color'], ['v-model' => 'invoice_form.color', '@input' => 'onChangeColorInput', 'id' => 'color', 'class' => 'form-control color-hex', 'required' => 'required']) !!} + {!! Form::text('color', setting('invoice.color'), ['v-model' => 'invoice_form.color', '@input' => 'onChangeColorInput', 'id' => 'color', 'class' => 'form-control color-hex', 'required' => 'required']) !!} {!! $errors->first('color', '

:message

') !!} @stack('color_input_end') - {!! Form::hidden('_template', $setting['template']) !!} + {!! Form::hidden('_template', setting('invoice.template')) !!} {!! Form::hidden('_prefix', 'invoice') !!} {!! Form::close() !!} diff --git a/resources/views/settings/company/edit.blade.php b/resources/views/settings/company/edit.blade.php index 0f9ae0507..29ba258d9 100644 --- a/resources/views/settings/company/edit.blade.php +++ b/resources/views/settings/company/edit.blade.php @@ -3,7 +3,7 @@ @section('title', trans_choice('general.companies', 1)) @section('content') - {!! Form::model($setting, [ + {!! Form::open([ 'id' => 'setting', 'method' => 'PATCH', 'route' => 'settings.update', @@ -18,15 +18,15 @@
- {{ Form::textGroup('name', trans('settings.company.name'), 'building') }} + {{ Form::textGroup('name', trans('settings.company.name'), 'building', ['required' => 'required'], setting('company.name')) }} - {{ Form::textGroup('email', trans('settings.company.email'), 'envelope') }} + {{ Form::textGroup('email', trans('settings.company.email'), 'envelope', ['required' => 'required'], setting('company.email')) }} - {{ Form::textGroup('tax_number', trans('general.tax_number'), 'percent', []) }} + {{ Form::textGroup('tax_number', trans('general.tax_number'), 'percent', [], setting('company.tax_number')) }} - {{ Form::textGroup('phone', trans('settings.company.phone'), 'phone', []) }} + {{ Form::textGroup('phone', trans('settings.company.phone'), 'phone', [], setting('company.phone')) }} - {{ Form::textareaGroup('address', trans('settings.company.address')) }} + {{ Form::textareaGroup('address', trans('settings.company.address'), null, setting('company.address')) }} {{ Form::fileGroup('logo', trans('settings.company.logo')) }}
diff --git a/resources/views/settings/default/edit.blade.php b/resources/views/settings/default/edit.blade.php index 5c9595c1a..84a1a52b4 100644 --- a/resources/views/settings/default/edit.blade.php +++ b/resources/views/settings/default/edit.blade.php @@ -3,7 +3,7 @@ @section('title', trans_choice('general.defaults', 1)) @section('content') - {!! Form::model($setting, [ + {!! Form::open([ 'id' => 'setting', 'method' => 'PATCH', 'route' => 'settings.update', @@ -18,19 +18,19 @@
- {{ Form::selectGroup('account', trans_choice('general.accounts', 1), 'university', $accounts, !empty($setting['account']) ? $setting['account'] : null, []) }} + {{ Form::selectGroup('account', trans_choice('general.accounts', 1), 'university', $accounts, setting('default.account'), []) }} - {{ Form::selectGroup('currency', trans_choice('general.currencies', 1), 'exchange-alt', $currencies, !empty($setting['currency']) ? $setting['currency'] : null, []) }} + {{ Form::selectGroup('currency', trans_choice('general.currencies', 1), 'exchange-alt', $currencies, setting('default.currency'), []) }} - {{ Form::selectGroup('tax', trans_choice('general.taxes', 1), 'percent', $taxes, !empty($setting['tax']) ? $setting['tax'] : null, []) }} + {{ Form::selectGroup('tax', trans_choice('general.taxes', 1), 'percent', $taxes, setting('default.tax'), []) }} - {{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods, !empty($setting['payment_method']) ? $setting['payment_method'] : null, []) }} + {{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods, setting('default.payment_method'), []) }} - {{ Form::selectGroup('locale', trans_choice('general.languages', 1), 'flag', language()->allowed(), !empty($setting['locale']) ? $setting['locale'] : null, []) }} + {{ Form::selectGroup('locale', trans_choice('general.languages', 1), 'flag', language()->allowed(), setting('default.locale'), []) }} - {{ Form::selectGroup('list_limit', trans('settings.default.list_limit'), 'columns', ['10' => '10', '25' => '25', '50' => '50', '100' => '100'], !empty($setting['list_limit']) ? $setting['list_limit'] : null, []) }} + {{ Form::selectGroup('list_limit', trans('settings.default.list_limit'), 'columns', ['10' => '10', '25' => '25', '50' => '50', '100' => '100'], setting('default.list_limit'), []) }} - {{ Form::radioGroup('use_gravatar', trans('settings.default.use_gravatar'), $setting->get('use_gravatar')) }} + {{ Form::radioGroup('use_gravatar', trans('settings.default.use_gravatar'), setting('default.use_gravatar')) }}
diff --git a/resources/views/settings/email/edit.blade.php b/resources/views/settings/email/edit.blade.php index 0a0de079c..c2d497ebe 100644 --- a/resources/views/settings/email/edit.blade.php +++ b/resources/views/settings/email/edit.blade.php @@ -3,7 +3,7 @@ @section('title', trans('general.email')) @section('content') - {!! Form::model($setting, [ + {!! Form::open([ 'id' => 'setting', 'method' => 'PATCH', 'route' => 'settings.email.update', @@ -64,9 +64,9 @@
- {{ Form::selectGroup('protocol', trans('settings.email.protocol'), 'share', $email_protocols, !empty($setting['protocol']) ? $setting['protocol'] : null, ['change' => 'onChangeProtocol']) }} + {{ Form::selectGroup('protocol', trans('settings.email.protocol'), 'share', $email_protocols, setting('email.protocol'), ['change' => 'onChangeProtocol']) }} - {{ Form::textGroup('sendmail_path', trans('settings.email.sendmail_path'), 'road', [':disabled'=> 'email.sendmailPath']) }} + {{ Form::textGroup('sendmail_path', trans('settings.email.sendmail_path'), 'road', [':disabled'=> 'email.sendmailPath'], setting('email.sendmail_path')) }} {{ Form::textGroup('smtp_host', trans('settings.email.smtp.host'), 'paper-plane', [':disabled' => 'email.smtpHost']) }} diff --git a/resources/views/settings/invoice/edit.blade.php b/resources/views/settings/invoice/edit.blade.php index 7f4a0d2a1..f2e1731dd 100644 --- a/resources/views/settings/invoice/edit.blade.php +++ b/resources/views/settings/invoice/edit.blade.php @@ -3,7 +3,7 @@ @section('title', trans_choice('general.invoices', 1)) @section('content') - {!! Form::model($setting, [ + {!! Form::open([ 'id' => 'setting', 'method' => 'PATCH', 'route' => 'settings.update', @@ -18,15 +18,15 @@
- {{ Form::textGroup('number_prefix', trans('settings.invoice.prefix'), 'font', []) }} + {{ Form::textGroup('number_prefix', trans('settings.invoice.prefix'), 'font', [], setting('invoice.number_prefix')) }} - {{ Form::textGroup('number_digit', trans('settings.invoice.digit'), 'text-width', []) }} + {{ Form::textGroup('number_digit', trans('settings.invoice.digit'), 'text-width', [], setting('invoice.number_digit')) }} - {{ Form::textGroup('number_next', trans('settings.invoice.next'), 'chevron-right', []) }} + {{ Form::textGroup('number_next', trans('settings.invoice.next'), 'chevron-right', [], setting('invoice.number_next')) }} - {{ Form::selectGroup('payment_terms', trans('settings.invoice.payment_terms'), 'calendar', $payment_terms, $setting['payment_terms'], []) }} + {{ Form::selectGroup('payment_terms', trans('settings.invoice.payment_terms'), 'calendar', $payment_terms, setting('invoice.payment_terms'), []) }} - {{ Form::textGroup('title', trans('settings.invoice.title'), 'font', []) }} + {{ Form::textGroup('title', trans('settings.invoice.title'), 'font', [], setting('invoice.title')) }} {{ Form::textGroup('subheading', trans('settings.invoice.subheading'), 'font', []) }} @@ -34,11 +34,11 @@ {{ Form::textareaGroup('footer', trans('general.footer')) }} - {{ Form::invoice_text('item_name', trans('settings.invoice.item_name'), 'font', $item_names, null, [], 'item_name_input', null) }} + {{ Form::invoice_text('item_name', trans('settings.invoice.item_name'), 'font', $item_names, setting('invoice.item_name'), [], 'item_name_input', null) }} - {{ Form::invoice_text('price_name', trans('settings.invoice.price_name'), 'font', $price_names, null, [], 'price_name_input', null) }} + {{ Form::invoice_text('price_name', trans('settings.invoice.price_name'), 'font', $price_names, setting('invoice.price_name'), [], 'price_name_input', null) }} - {{ Form::invoice_text('quantity_name', trans('settings.invoice.quantity_name'), 'font', $quantity_names, null, [], 'quantity_name_input', null) }} + {{ Form::invoice_text('quantity_name', trans('settings.invoice.quantity_name'), 'font', $quantity_names, setting('invoice.quantity_name'), [], 'quantity_name_input', null) }}
{!! Form::label('invoice_template', trans_choice('general.templates', 1), ['class' => 'form-control-label']) !!} diff --git a/resources/views/settings/localisation/edit.blade.php b/resources/views/settings/localisation/edit.blade.php index 1d259817f..c8017802b 100644 --- a/resources/views/settings/localisation/edit.blade.php +++ b/resources/views/settings/localisation/edit.blade.php @@ -3,7 +3,7 @@ @section('title', trans_choice('general.localisations', 1)) @section('content') - {!! Form::model($setting, [ + {!! Form::open([ 'id' => 'setting', 'method' => 'PATCH', 'route' => 'settings.update', @@ -18,17 +18,17 @@
- {{ Form::dateGroup('financial_start', trans('settings.localisation.financial_start'), 'calendar', ['id' => 'financial_start', 'class' => 'form-control datepicker', 'show-date-format' => 'j F', 'date-format' => 'd-m', 'autocomplete' => 'off'], $setting['financial_start']) }} + {{ Form::dateGroup('financial_start', trans('settings.localisation.financial_start'), 'calendar', ['id' => 'financial_start', 'class' => 'form-control datepicker', 'show-date-format' => 'j F', 'date-format' => 'd-m', 'autocomplete' => 'off'], setting('localisation.financial_start')) }} - {{ Form::selectGroupGroup('timezone', trans('settings.localisation.timezone'), 'globe', $timezones, $setting['timezone'], []) }} + {{ Form::selectGroupGroup('timezone', trans('settings.localisation.timezone'), 'globe', $timezones, setting('localisation.timezone'), []) }} - {{ Form::selectGroup('date_format', trans('settings.localisation.date.format'), 'calendar', $date_formats, $setting['date_format'], ['autocomplete' => 'off']) }} + {{ Form::selectGroup('date_format', trans('settings.localisation.date.format'), 'calendar', $date_formats, setting('localisation.date_format'), ['autocomplete' => 'off']) }} - {{ Form::selectGroup('date_separator', trans('settings.localisation.date.separator'), 'minus', $date_separators, $setting['date_separator'], []) }} + {{ Form::selectGroup('date_separator', trans('settings.localisation.date.separator'), 'minus', $date_separators, setting('localisation.date_separator'), []) }} - {{ Form::selectGroup('percent_position', trans('settings.localisation.percent.title'), 'percent', $percent_positions, $setting['percent_position'], []) }} + {{ Form::selectGroup('percent_position', trans('settings.localisation.percent.title'), 'percent', $percent_positions, setting('localisation.percent_position'), []) }} - {{ Form::selectGroup('discount_location', trans('settings.localisation.discount_location.name'), 'percent', $discount_locations, !empty($setting['discount_location']) ? $setting['discount_location'] : 'total', []) }} + {{ Form::selectGroup('discount_location', trans('settings.localisation.discount_location.name'), 'percent', $discount_locations, setting('localisation.discount_location'), []) }}
diff --git a/resources/views/settings/schedule/edit.blade.php b/resources/views/settings/schedule/edit.blade.php index aef91a769..ce2e9a522 100644 --- a/resources/views/settings/schedule/edit.blade.php +++ b/resources/views/settings/schedule/edit.blade.php @@ -3,7 +3,7 @@ @section('title', trans('settings.scheduling.name')) @section('content') - {!! Form::model($setting, [ + {!! Form::open([ 'id' => 'setting', 'method' => 'PATCH', 'route' => 'settings.update', @@ -18,13 +18,13 @@
- {{ Form::radioGroup('send_invoice_reminder', trans('settings.scheduling.send_invoice'), $setting->get('send_invoice_reminder')) }} + {{ Form::radioGroup('send_invoice_reminder', trans('settings.scheduling.send_invoice'), setting('schedule.send_invoice_reminder')) }} - {{ Form::textGroup('invoice_days', trans('settings.scheduling.invoice_days'), 'calendar', []) }} + {{ Form::textGroup('invoice_days', trans('settings.scheduling.invoice_days'), 'calendar', [], setting('schedule.invoice_days')) }} - {{ Form::radioGroup('send_bill_reminder', trans('settings.scheduling.send_bill'), $setting->get('send_bill_reminder')) }} + {{ Form::radioGroup('send_bill_reminder', trans('settings.scheduling.send_bill'), setting('schedule.send_bill_reminder')) }} - {{ Form::textGroup('bill_days', trans('settings.scheduling.bill_days'), 'calendar', []) }} + {{ Form::textGroup('bill_days', trans('settings.scheduling.bill_days'), 'calendar', [], setting('schedule.bill_days')) }}