mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Added static data to the API
This commit is contained in:
parent
7720c45ae2
commit
01946f7bc8
@ -4,6 +4,7 @@ use Auth;
|
|||||||
use Utils;
|
use Utils;
|
||||||
use Response;
|
use Response;
|
||||||
use Input;
|
use Input;
|
||||||
|
use Cache;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\AccountToken;
|
use App\Models\AccountToken;
|
||||||
@ -72,4 +73,15 @@ class AccountApiController extends BaseAPIController
|
|||||||
return $this->response($response);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,19 +148,7 @@ class StartupCheck
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check data has been cached
|
// Check data has been cached
|
||||||
$cachedTables = [
|
$cachedTables = unserialize(CACHED_TABLES);
|
||||||
'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',
|
|
||||||
];
|
|
||||||
if (Input::has('clear_cache')) {
|
if (Input::has('clear_cache')) {
|
||||||
Session::flash('message', 'Cache cleared');
|
Session::flash('message', 'Cache cleared');
|
||||||
}
|
}
|
||||||
|
@ -196,6 +196,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function()
|
|||||||
{
|
{
|
||||||
Route::resource('ping', 'ClientApiController@ping');
|
Route::resource('ping', 'ClientApiController@ping');
|
||||||
Route::post('login', 'AccountApiController@login');
|
Route::post('login', 'AccountApiController@login');
|
||||||
|
Route::get('static', 'AccountApiController@getStaticData');
|
||||||
Route::get('accounts', 'AccountApiController@show');
|
Route::get('accounts', 'AccountApiController@show');
|
||||||
Route::resource('clients', 'ClientApiController');
|
Route::resource('clients', 'ClientApiController');
|
||||||
Route::get('quotes/{client_id?}', 'QuoteApiController@index');
|
Route::get('quotes/{client_id?}', 'QuoteApiController@index');
|
||||||
@ -487,7 +488,6 @@ if (!defined('CONTACT_EMAIL')) {
|
|||||||
define('SOCIAL_GITHUB', 'GitHub');
|
define('SOCIAL_GITHUB', 'GitHub');
|
||||||
define('SOCIAL_LINKEDIN', 'LinkedIn');
|
define('SOCIAL_LINKEDIN', 'LinkedIn');
|
||||||
|
|
||||||
|
|
||||||
$creditCards = [
|
$creditCards = [
|
||||||
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
|
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
|
||||||
2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'],
|
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'],
|
8 => ['card' => 'images/credit_cards/Test-Diners-Icon.png', 'text' => 'Diners'],
|
||||||
16 => ['card' => 'images/credit_cards/Test-Discover-Icon.png', 'text' => 'Discover']
|
16 => ['card' => 'images/credit_cards/Test-Discover-Icon.png', 'text' => 'Discover']
|
||||||
];
|
];
|
||||||
|
|
||||||
define('CREDIT_CARDS', serialize($creditCards));
|
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)
|
function uctrans($text)
|
||||||
{
|
{
|
||||||
return ucwords(trans($text));
|
return ucwords(trans($text));
|
||||||
|
@ -642,6 +642,7 @@ class Utils
|
|||||||
//'Access-Control-Allow-Headers' => 'Origin, Content-Type, Accept, Authorization, X-Requested-With',
|
//'Access-Control-Allow-Headers' => 'Origin, Content-Type, Accept, Authorization, X-Requested-With',
|
||||||
//'Access-Control-Allow-Credentials' => 'true',
|
//'Access-Control-Allow-Credentials' => 'true',
|
||||||
'X-Total-Count' => $count,
|
'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-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-Remaining' - The number of remaining requests in the current period
|
||||||
//'X-Rate-Limit-Reset' - The number of seconds left in the current period,
|
//'X-Rate-Limit-Reset' - The number of seconds left in the current period,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user