From b7920a072a219bbd0dcee3b3e26031502c582467 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 12 Sep 2019 11:28:41 +1000 Subject: [PATCH] Set all ID's to strings for consistency --- app/Http/Controllers/BaseController.php | 6 ++++- app/Models/Activity.php | 2 +- app/Models/Bank.php | 3 +-- app/Models/Country.php | 2 +- app/Models/Currency.php | 2 +- app/Models/Gateway.php | 2 +- app/Models/GatewayType.php | 2 +- app/Models/GroupSetting.php | 2 +- app/Models/Industry.php | 2 +- app/Models/Language.php | 2 +- app/Models/PaymentType.php | 2 +- app/Models/Size.php | 2 +- app/Models/StaticModel.php | 24 +++++++++++++++++++ app/Models/Timezone.php | 2 +- app/Transformers/ClientTransformer.php | 1 + app/Transformers/CompanyTransformer.php | 6 ++--- app/Transformers/InvoiceItemTransformer.php | 2 +- app/Transformers/InvoiceTransformer.php | 4 ++-- app/Transformers/QuoteTransformer.php | 6 ++--- .../RecurringInvoiceTransformer.php | 6 ++--- .../RecurringQuoteTransformer.php | 4 ++-- 21 files changed, 56 insertions(+), 28 deletions(-) create mode 100644 app/Models/StaticModel.php diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index eaa53d22b9..65b930950b 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -147,6 +147,9 @@ class BaseController extends Controller $data = $this->createCollection($query, $transformer, $this->entity_type); + if(request()->include_static) + $data['static'] = Statics::company(auth()->user()->getCompany()->getLocale()); + return $this->response($data); } @@ -210,8 +213,9 @@ class BaseController extends Controller $data = $this->createItem($item, $transformer, $this->entity_type); - if(request()->include_static) + if(request()->include_static) $data['static'] = Statics::company(auth()->user()->getCompany()->getLocale()); + return $this->response($data); diff --git a/app/Models/Activity.php b/app/Models/Activity.php index ffebfcf6fd..002a2ae6dd 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -13,7 +13,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class Activity extends Model +class Activity extends StaticModel { const CREATE_CLIENT=1; diff --git a/app/Models/Bank.php b/app/Models/Bank.php index adbb64040c..544cf2a532 100644 --- a/app/Models/Bank.php +++ b/app/Models/Bank.php @@ -11,12 +11,11 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Model; /** * Class Bank. */ -class Bank extends Model +class Bank extends StaticModel { /** * @var bool diff --git a/app/Models/Country.php b/app/Models/Country.php index bbd494a6f7..79556d5f6c 100644 --- a/app/Models/Country.php +++ b/app/Models/Country.php @@ -13,7 +13,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class Country extends Model +class Country extends StaticModel { public $timestamps = false; diff --git a/app/Models/Currency.php b/app/Models/Currency.php index 8b529768f9..d45727de73 100644 --- a/app/Models/Currency.php +++ b/app/Models/Currency.php @@ -13,7 +13,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class Currency extends Model +class Currency extends StaticModel { public $timestamps = false; diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index d7d9f42483..b1ae677caa 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -14,7 +14,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use Omnipay\Omnipay; -class Gateway extends Model +class Gateway extends StaticModel { /** diff --git a/app/Models/GatewayType.php b/app/Models/GatewayType.php index 3902b9a17a..49a4a4c646 100644 --- a/app/Models/GatewayType.php +++ b/app/Models/GatewayType.php @@ -14,7 +14,7 @@ namespace App\Models; use App\Models\Gateway; use Illuminate\Database\Eloquent\Model; -class GatewayType extends Model +class GatewayType extends StaticModel { public $timestamps = false; diff --git a/app/Models/GroupSetting.php b/app/Models/GroupSetting.php index 3c86df78a2..7714b5bcce 100644 --- a/app/Models/GroupSetting.php +++ b/app/Models/GroupSetting.php @@ -21,7 +21,7 @@ use Hashids\Hashids; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\Model; -class GroupSetting extends Model +class GroupSetting extends StaticModel { public $timestamps = false; diff --git a/app/Models/Industry.php b/app/Models/Industry.php index f1b42949b9..6c67b4209e 100644 --- a/app/Models/Industry.php +++ b/app/Models/Industry.php @@ -13,7 +13,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class Industry extends Model +class Industry extends StaticModel { public $timestamps = false; } diff --git a/app/Models/Language.php b/app/Models/Language.php index 788d78e928..6a53f340eb 100644 --- a/app/Models/Language.php +++ b/app/Models/Language.php @@ -13,7 +13,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class Language extends Model +class Language extends StaticModel { public $timestamps = false; diff --git a/app/Models/PaymentType.php b/app/Models/PaymentType.php index 21e4166df0..d1384d665b 100644 --- a/app/Models/PaymentType.php +++ b/app/Models/PaymentType.php @@ -13,7 +13,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class PaymentType extends Model +class PaymentType extends StaticModel { /** * @var bool diff --git a/app/Models/Size.php b/app/Models/Size.php index 73e3d2aea1..ded5903233 100644 --- a/app/Models/Size.php +++ b/app/Models/Size.php @@ -16,7 +16,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class Size. */ -class Size extends Model +class Size extends StaticModel { /** diff --git a/app/Models/StaticModel.php b/app/Models/StaticModel.php new file mode 100644 index 0000000000..54d2d6bf32 --- /dev/null +++ b/app/Models/StaticModel.php @@ -0,0 +1,24 @@ +attributes['id']; + } + +} diff --git a/app/Models/Timezone.php b/app/Models/Timezone.php index e3bc34f6fc..5c6b772d1c 100644 --- a/app/Models/Timezone.php +++ b/app/Models/Timezone.php @@ -13,7 +13,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class Timezone extends Model +class Timezone extends StaticModel { /** * @var bool diff --git a/app/Transformers/ClientTransformer.php b/app/Transformers/ClientTransformer.php index 28b140ca1b..07537bf240 100644 --- a/app/Transformers/ClientTransformer.php +++ b/app/Transformers/ClientTransformer.php @@ -59,6 +59,7 @@ class ClientTransformer extends EntityTransformer 'website' => $client->website ?: '', 'private_notes' => $client->private_notes ?: '', 'balance' => $client->balance ?: '', + 'currency_id' => (string)$client->currency_id ?: '', 'paid_to_date' => $client->paid_to_date ?: '', 'last_login' => $client->last_login ?: '', 'address1' => $client->address1 ?: '', diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index 19f41a57ac..d8dddafbf9 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -72,11 +72,11 @@ class CompanyTransformer extends EntityTransformer 'postal_code' => $company->postal_code, 'work_phone' => $company->work_phone, 'work_email' => $company->work_email, - 'country_id' => (int) $company->country_id, + 'country_id' => (string) $company->country_id, 'vat_number' => $company->vat_number, 'id_number' => $company->id_number, - 'size_id' => (int) $company->size_id, - 'industry_id' => (int) $company->industry_id, + 'size_id' => (string) $company->size_id, + 'industry_id' => (string) $company->industry_id, 'settings' => $company->settings, 'updated_at' => $company->updated_at, 'deleted_at' => $company->deleted_at, diff --git a/app/Transformers/InvoiceItemTransformer.php b/app/Transformers/InvoiceItemTransformer.php index f4642f2185..7bae8540a9 100644 --- a/app/Transformers/InvoiceItemTransformer.php +++ b/app/Transformers/InvoiceItemTransformer.php @@ -28,7 +28,7 @@ class InvoiceItemTransformer extends EntityTransformer 'tax_rate1' => (float) ($item->tax_rate1 ?: 0.0), 'tax_name2' => $item->tax_name2 ? $item->tax_name2 : '', 'tax_rate2' => (float) ($item->tax_rate2 ?: 0.0), - 'invoice_item_type_id' => (int) $item->invoice_item_type_id, + 'invoice_item_type_id' => (string) $item->invoice_item_type_id, 'custom_value1' => $item->custom_value1 ?: '', 'custom_value2' => $item->custom_value2 ?: '', 'discount' => (float) $item->discount, diff --git a/app/Transformers/InvoiceTransformer.php b/app/Transformers/InvoiceTransformer.php index 3487b5b328..14ba888581 100644 --- a/app/Transformers/InvoiceTransformer.php +++ b/app/Transformers/InvoiceTransformer.php @@ -82,8 +82,8 @@ class InvoiceTransformer extends EntityTransformer 'id' => $this->encodePrimaryKey($invoice->id), 'amount' => (float) $invoice->amount, 'balance' => (float) $invoice->balance, - 'client_id' => (int) $invoice->client_id, - 'status_id' => (int) ($invoice->status_id ?: 1), + 'client_id' => (string) $invoice->client_id, + 'status_id' => (string) ($invoice->status_id ?: 1), 'updated_at' => $invoice->updated_at, 'archived_at' => $invoice->deleted_at, 'invoice_number' => $invoice->invoice_number, diff --git a/app/Transformers/QuoteTransformer.php b/app/Transformers/QuoteTransformer.php index 93fb9efafb..6f16d93bdf 100644 --- a/app/Transformers/QuoteTransformer.php +++ b/app/Transformers/QuoteTransformer.php @@ -82,8 +82,8 @@ class QuoteTransformer extends EntityTransformer 'id' => $this->encodePrimaryKey($quote->id), 'amount' => (float) $quote->amount, 'balance' => (float) $quote->balance, - 'client_id' => (int) $quote->client_id, - 'status_id' => (int) ($quote->status_id ?: 1), + 'client_id' => (string) $quote->client_id, + 'status_id' => (string) ($quote->status_id ?: 1), 'updated_at' => $quote->updated_at, 'archived_at' => $quote->deleted_at, 'quote_number' => $quote->quote_number, @@ -95,7 +95,7 @@ class QuoteTransformer extends EntityTransformer 'public_notes' => $quote->public_notes ?: '', 'private_notes' => $quote->private_notes ?: '', 'is_deleted' => (bool) $quote->is_deleted, - 'quote_type_id' => (int) $quote->quote_type_id, + 'quote_type_id' => (string) $quote->quote_type_id, 'tax_name1' => $quote->tax_name1 ? $quote->tax_name1 : '', 'tax_rate1' => (float) $quote->tax_rate1, 'tax_name2' => $quote->tax_name2 ? $quote->tax_name2 : '', diff --git a/app/Transformers/RecurringInvoiceTransformer.php b/app/Transformers/RecurringInvoiceTransformer.php index a45abe86b1..7c189598c3 100644 --- a/app/Transformers/RecurringInvoiceTransformer.php +++ b/app/Transformers/RecurringInvoiceTransformer.php @@ -83,8 +83,8 @@ class RecurringInvoiceTransformer extends EntityTransformer 'id' => $this->encodePrimaryKey($invoice->id), 'amount' => (float) $invoice->amount, 'balance' => (float) $invoice->balance, - 'client_id' => (int) $invoice->client_id, - 'status_id' => (int) ($invoice->status_id ?: 1), + 'client_id' => (string) $invoice->client_id, + 'status_id' => (string) ($invoice->status_id ?: 1), 'updated_at' => $invoice->updated_at, 'archived_at' => $invoice->deleted_at, 'discount' => (float) $invoice->discount, @@ -113,7 +113,7 @@ class RecurringInvoiceTransformer extends EntityTransformer 'custom_text_value2' => $invoice->custom_text_value2 ?: '', 'backup' => $invoice->backup ?: '', 'settings' => $invoice->settings, - 'frequency_id' => (int) $invoice->frequency_id, + 'frequency_id' => (string) $invoice->frequency_id, 'start_date' => $invoice->start_date, 'last_sent_date' => $invoice->last_sent_date, 'next_send_date' => $invoice->next_send_date, diff --git a/app/Transformers/RecurringQuoteTransformer.php b/app/Transformers/RecurringQuoteTransformer.php index 5739146241..b20cd42608 100644 --- a/app/Transformers/RecurringQuoteTransformer.php +++ b/app/Transformers/RecurringQuoteTransformer.php @@ -83,8 +83,8 @@ class RecurringQuoteTransformer extends EntityTransformer 'id' => $this->encodePrimaryKey($quote->id), 'amount' => (float) $quote->amount, 'balance' => (float) $quote->balance, - 'client_id' => (int) $quote->client_id, - 'status_id' => (int) ($quote->status_id ?: 1), + 'client_id' => (string) $quote->client_id, + 'status_id' => (string) ($quote->status_id ?: 1), 'updated_at' => $quote->updated_at, 'archived_at' => $quote->deleted_at, 'discount' => (float) $quote->discount,