'bool', 'design_id' => 'string', 'name' => 'string', 'company_logo' => 'string', 'website' => 'string', 'address1' => 'string', 'address2' => 'string', 'city' => 'string', 'state' => 'string', 'postal_code' => 'string', 'phone' => 'string', 'email' => 'string', 'country_id' => 'string', 'currency_id' => 'string', 'vat_number' => 'string', 'id_number' => 'string', 'tax_name1' => 'string', 'tax_name2' => 'string', 'tax_name3' => 'string', 'tax_rate1' => 'float', 'tax_rate2' => 'float', 'tax_rate3' => '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', 'military_time' => 'bool', 'language_id' => 'string', 'show_currency_code' => 'bool', 'payment_terms' => 'integer', 'custom_value1' => 'string', 'custom_value2' => 'string', 'custom_value3' => 'string', 'custom_value4' => 'string', // 'custom_label1' => 'string', // 'custom_label2' => 'string', // 'custom_label3' => 'string', // 'custom_label4' => 'string', // 'custom_client_label1' => 'string', // 'custom_client_label2' => 'string', // 'custom_client_label3' => 'string', // 'custom_client_label4' => 'string', // 'custom_client_contact_label1' => 'string', // 'custom_client_contact_label2' => 'string', // 'custom_client_contact_label3' => 'string', // 'custom_client_contact_label4' => 'string', // 'custom_invoice_label1' => 'string', // 'custom_invoice_label2' => 'string', // 'custom_invoice_label3' => 'string', // 'custom_invoice_label4' => 'string', // 'custom_product_label1' => 'string', // 'custom_product_label2' => 'string', // 'custom_product_label3' => 'string', // 'custom_product_label4' => 'string', // 'custom_task_label1' => 'string', // 'custom_task_label2' => 'string', // 'custom_task_label3' => 'string', // 'custom_task_label4' => 'string', // 'custom_expense_label1' => 'string', // 'custom_expense_label2' => 'string', // 'custom_expense_label3' => 'string', // 'custom_expense_label4' => 'string', 'custom_invoice_taxes1' => 'bool', 'custom_invoice_taxes2' => 'bool', 'custom_invoice_taxes3' => 'bool', 'custom_invoice_taxes4' => 'bool', 'default_task_rate' => 'float', 'send_reminders' => 'bool', 'show_tasks_in_portal' => 'bool', 'custom_message_dashboard' => 'string', 'custom_message_unpaid_invoice' => 'string', 'custom_message_paid_invoice' => 'string', 'custom_message_unapproved_quote' => 'string', 'lock_sent_invoices' => 'bool', 'auto_archive_invoice' => 'bool', 'inclusive_taxes' => 'bool', 'invoice_number_prefix' => 'string', 'invoice_number_pattern' => 'string', 'invoice_number_counter' => 'integer', 'quote_number_prefix' => 'string', 'quote_number_pattern' => 'string', 'quote_number_counter' => 'integer', 'client_number_prefix' => 'string', 'client_number_pattern' => 'string', 'client_number_counter' => 'integer', 'credit_number_prefix' => 'string', 'credit_number_pattern' => 'string', 'credit_number_counter' => 'integer', 'shared_invoice_quote_counter' => 'bool', 'recurring_invoice_number_prefix' => 'string', 'reset_counter_frequency_id' => 'integer', 'reset_counter_date' => 'string', 'counter_padding' => 'integer', 'design' => 'string', 'company_gateways' => 'string', ]; /** * Array of variables which * cannot be modified client side */ public static $protected_fields = [ // 'credit_number_counter', // 'invoice_number_counter', // 'quote_number_counter', ]; /** * Cast object values and return entire class * prevents missing properties from not being returned * and always ensure an up to date class is returned * * @return \stdClass */ public function __construct($obj) { // parent::__construct($obj); } /** * Provides class defaults on init * @return object */ public static function defaults() : \stdClass { $config = json_decode(config('ninja.settings')); $data = (object)get_class_vars(CompanySettings::class); unset($data->casts); unset($data->protected_fields); $data->timezone_id = (string)config('ninja.i18n.timezone_id'); $data->currency_id = (string)config('ninja.i18n.currency_id'); $data->language_id = (string)config('ninja.i18n.language_id'); $data->payment_terms = (int)config('ninja.i18n.payment_terms'); $data->military_time = (bool)config('ninja.i18n.military_time'); $data->date_format_id = (string)config('ninja.i18n.date_format_id'); $data->country_id = (string)config('ninja.i18n.country_id'); $data->translations = (object) []; return self::setCasts($data, self::$casts); } /** * In case we update the settings object in the future we * need to provide a fallback catch on old settings objects which will * set new properties to the object prior to being returned. * * @param object $data The settings object to be checked */ public static function setProperties($settings) :\stdClass { $company_settings = (object)get_class_vars(CompanySettings::class); foreach($company_settings as $key => $value) { if(!property_exists($settings, $key)) $settings->{$key} = self::castAttribute($key, $company_settings->{$key}); } return $settings; } }