diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 704ec79b3dbc..75ef6ac8a383 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -4,6 +4,7 @@ use Auth; use Utils; use Response; use Input; +use Cache; use App\Models\Client; use App\Models\Account; use App\Models\AccountToken; @@ -72,4 +73,15 @@ class AccountApiController extends BaseAPIController return $this->response($response); } + public function getStaticData() + { + $data = []; + + $cachedTables = unserialize(CACHED_TABLES); + foreach ($cachedTables as $name => $class) { + $data[$name] = Cache::get($name); + } + + return $this->response($data); + } } diff --git a/app/Http/Middleware/StartupCheck.php b/app/Http/Middleware/StartupCheck.php index 74d9c4c8ae5d..c87e405df86f 100644 --- a/app/Http/Middleware/StartupCheck.php +++ b/app/Http/Middleware/StartupCheck.php @@ -148,19 +148,7 @@ class StartupCheck } // Check data has been cached - $cachedTables = [ - 'currencies' => 'App\Models\Currency', - 'sizes' => 'App\Models\Size', - 'industries' => 'App\Models\Industry', - 'timezones' => 'App\Models\Timezone', - 'dateFormats' => 'App\Models\DateFormat', - 'datetimeFormats' => 'App\Models\DatetimeFormat', - 'languages' => 'App\Models\Language', - 'paymentTerms' => 'App\Models\PaymentTerm', - 'paymentTypes' => 'App\Models\PaymentType', - 'countries' => 'App\Models\Country', - 'invoiceDesigns' => 'App\Models\InvoiceDesign', - ]; + $cachedTables = unserialize(CACHED_TABLES); if (Input::has('clear_cache')) { Session::flash('message', 'Cache cleared'); } diff --git a/app/Http/routes.php b/app/Http/routes.php index 0094629aa12c..2251193bbcc1 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -196,6 +196,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function() { Route::resource('ping', 'ClientApiController@ping'); Route::post('login', 'AccountApiController@login'); + Route::get('static', 'AccountApiController@getStaticData'); Route::get('accounts', 'AccountApiController@show'); Route::resource('clients', 'ClientApiController'); Route::get('quotes/{client_id?}', 'QuoteApiController@index'); @@ -487,7 +488,6 @@ if (!defined('CONTACT_EMAIL')) { define('SOCIAL_GITHUB', 'GitHub'); define('SOCIAL_LINKEDIN', 'LinkedIn'); - $creditCards = [ 1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'], 2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'], @@ -495,9 +495,23 @@ if (!defined('CONTACT_EMAIL')) { 8 => ['card' => 'images/credit_cards/Test-Diners-Icon.png', 'text' => 'Diners'], 16 => ['card' => 'images/credit_cards/Test-Discover-Icon.png', 'text' => 'Discover'] ]; - define('CREDIT_CARDS', serialize($creditCards)); + $cachedTables = [ + 'currencies' => 'App\Models\Currency', + 'sizes' => 'App\Models\Size', + 'industries' => 'App\Models\Industry', + 'timezones' => 'App\Models\Timezone', + 'dateFormats' => 'App\Models\DateFormat', + 'datetimeFormats' => 'App\Models\DatetimeFormat', + 'languages' => 'App\Models\Language', + 'paymentTerms' => 'App\Models\PaymentTerm', + 'paymentTypes' => 'App\Models\PaymentType', + 'countries' => 'App\Models\Country', + 'invoiceDesigns' => 'App\Models\InvoiceDesign', + ]; + define('CACHED_TABLES', serialize($cachedTables)); + function uctrans($text) { return ucwords(trans($text)); diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 1df5d436c744..ab03f9796b8c 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -642,6 +642,7 @@ class Utils //'Access-Control-Allow-Headers' => 'Origin, Content-Type, Accept, Authorization, X-Requested-With', //'Access-Control-Allow-Credentials' => 'true', 'X-Total-Count' => $count, + 'X-Ninja-Version' => NINJA_VERSION, //'X-Rate-Limit-Limit' - The number of allowed requests in the current period //'X-Rate-Limit-Remaining' - The number of remaining requests in the current period //'X-Rate-Limit-Reset' - The number of seconds left in the current period,