Sort response in alphabetical order by key

This commit is contained in:
David Bomba 2019-09-23 21:29:30 +10:00
parent 1e1be26980
commit 3ad0a3ff9a
6 changed files with 34 additions and 25 deletions

View File

@ -20,20 +20,21 @@ use App\Models\Company;
class CompanySettings extends BaseSettings
{
public $start_of_week = '';
public $financial_year_start = '';
public $enable_modules = false;
public $timezone_id = '';
public $date_format_id = '';
public $datetime_format_id = '';
public $military_time = false;
public $start_of_week = '';
public $financial_year_start = '';
public $language_id = '';
public $precision = 2;
public $show_currency_symbol = true;
public $show_currency_code = false;
public $payment_terms;
public $payment_terms_id = 1;
public $custom_label1 = '';
public $custom_value1 = '';
@ -127,11 +128,10 @@ class CompanySettings extends BaseSettings
public $show_item_taxes = false;
public $fill_products = false;
public $tax_name1 = '';
public $tax_rate1 = '';
public $tax_rate1 = 0;
public $tax_name2 = '';
public $tax_rate2 = '';
public $tax_rate2 = 0;
public $enable_second_tax_rate = false;
public $enable_modules = false;
public $payment_type_id = '';
public $convert_products = false;
public $custom_fields = '';
@ -149,9 +149,9 @@ class CompanySettings extends BaseSettings
public $email_template_reminder1 = '';
public $email_template_reminder2 = '';
public $email_template_reminder3 = '';
public $has_custom_design1 = '';
public $has_custom_design2 = '';
public $has_custom_design3 = '';
public $has_custom_design1 = false;
public $has_custom_design2 = false;
public $has_custom_design3 = false;
public $enable_portal_password = false;
public $show_accept_invoice_terms = false;
public $show_accept_quote_terms = false;
@ -159,10 +159,15 @@ class CompanySettings extends BaseSettings
public $require_quote_signature = false;
public static $casts = [
'require_invoice_signature' => 'false',
'require_quote_signature' => 'false',
'show_accept_quote_terms' => 'false',
'show_accept_invoice_terms' => 'false',
'has_custom_design1' => 'bool',
'has_custom_design2' => 'bool',
'has_custom_design3' => 'bool',
'tax_rate1' => 'float',
'tax_rate2' => 'float',
'require_invoice_signature' => 'bool',
'require_quote_signature' => 'bool',
'show_accept_quote_terms' => 'bool',
'show_accept_invoice_terms' => 'bool',
'timezone_id' => 'string',
'date_format_id' => 'string',
'datetime_format_id' => 'string',
@ -173,7 +178,7 @@ class CompanySettings extends BaseSettings
'precision' => 'int',
'show_currency_symbol' => 'bool',
'show_currency_code' => 'bool',
'payment_terms' => 'int',
'payment_terms_id' => 'string',
'custom_label1' => 'string',
'custom_value1' => 'string',
'custom_label2' => 'string',

View File

@ -197,9 +197,12 @@ class BaseController extends Controller
$response['static'] = Statics::company(auth()->user()->getCompany()->getLocale());
}
ksort($response);
$response = json_encode($response, JSON_PRETTY_PRINT);
$headers = self::getApiHeaders();
return response()->make($response, 200, $headers);

View File

@ -71,7 +71,7 @@ class Kernel extends HttpKernel
\App\Http\Middleware\StartupCheck::class,
\App\Http\Middleware\QueryLogging::class,
],
'db' => [
'api_db' => [
\App\Http\Middleware\SetDb::class,
],
'web_db' => [

View File

@ -64,22 +64,22 @@ return [
'from_name' => env('MAIL_FROM_NAME'),
],
'cached_tables' => [
'banks' => 'App\Models\Bank',
'countries' => 'App\Models\Country',
'currencies' => 'App\Models\Currency',
'sizes' => 'App\Models\Size',
'industries' => 'App\Models\Industry',
'timezones' => 'App\Models\Timezone',
'date_formats' => 'App\Models\DateFormat',
'datetime_formats' => 'App\Models\DatetimeFormat',
'gateways' => 'App\Models\Gateway',
'gateway_types' => 'App\Models\GatewayType',
'industries' => 'App\Models\Industry',
'languages' => 'App\Models\Language',
'payment_types' => 'App\Models\PaymentType',
'countries' => 'App\Models\Country',
'sizes' => 'App\Models\Size',
'timezones' => 'App\Models\Timezone',
//'invoiceDesigns' => 'App\Models\InvoiceDesign',
//'invoiceStatus' => 'App\Models\InvoiceStatus',
//'frequencies' => 'App\Models\Frequency',
'gateways' => 'App\Models\Gateway',
'gateway_types' => 'App\Models\GatewayType',
//'fonts' => 'App\Models\Font',
'banks' => 'App\Models\Bank',
],
'payment_terms' => [
[

View File

@ -39,7 +39,7 @@ class RandomDataSeeder extends Seeder
$account = factory(\App\Models\Account::class)->create();
$company = factory(\App\Models\Company::class)->create([
'account_id' => $account->id,
'domain' => 'ninja.test:8000',
'domain' => config('ninja.site_url'),
]);
$account->default_company_id = $company->id;

View File

@ -29,9 +29,10 @@ Route::group(['api_secret_check','domain_db'], function () {
Route::post('api/v1/login', 'Auth\LoginController@apiLogin')->name('login.submit');
Route::post('api/v1/reset_password', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.reset');
});
Route::group(['middleware' => ['db','api_secret_check','token_auth'], 'prefix' =>'api/v1', 'as' => 'api.'], function () {
Route::group(['middleware' => ['api_db','api_secret_check','token_auth'], 'prefix' =>'api/v1', 'as' => 'api.'], function () {
Route::resource('clients', 'ClientController'); // name = (clients. index / create / show / update / destroy / edit