diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 14d04325fe82..614bf7df5826 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -70,6 +70,9 @@ class Activity extends StaticModel protected $casts = [ 'is_system' => 'boolean', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; public function backup() diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 57302ab69be8..b4ab1aa7fded 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -35,6 +35,12 @@ class BaseModel extends Model 'hashed_id' ]; + protected $casts = [ + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', + ]; + protected $dateFormat = 'Y-m-d H:i:s.u'; public function getHashedIdAttribute() diff --git a/app/Models/Client.php b/app/Models/Client.php index 0d675add42f9..abb4159e05f5 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -96,7 +96,10 @@ class Client extends BaseModel ]; */ protected $casts = [ - 'settings' => 'object' + 'settings' => 'object', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; public function gateway_tokens() diff --git a/app/Models/ClientGatewayToken.php b/app/Models/ClientGatewayToken.php index 576c9f370652..ccdd0f9f296c 100644 --- a/app/Models/ClientGatewayToken.php +++ b/app/Models/ClientGatewayToken.php @@ -22,6 +22,9 @@ class ClientGatewayToken extends BaseModel protected $casts = [ 'meta' => 'object', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; public function client() diff --git a/app/Models/Company.php b/app/Models/Company.php index e34d25a228b1..eea4e8e18b6a 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -74,7 +74,10 @@ class Company extends BaseModel ]; protected $casts = [ - 'settings' => 'object' + 'settings' => 'object', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; protected $with = [ diff --git a/app/Models/CompanyLedger.php b/app/Models/CompanyLedger.php index f2f430443afa..5f268dcc01f5 100644 --- a/app/Models/CompanyLedger.php +++ b/app/Models/CompanyLedger.php @@ -21,6 +21,12 @@ class CompanyLedger extends Model protected $guarded = [ 'id', ]; + + protected $casts = [ + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', + ]; public function user() { diff --git a/app/Models/CompanyToken.php b/app/Models/CompanyToken.php index a5b01e910a5f..c0cb5b5cd600 100644 --- a/app/Models/CompanyToken.php +++ b/app/Models/CompanyToken.php @@ -29,6 +29,12 @@ class CompanyToken extends Model // 'company', ]; + protected $casts = [ + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', + ]; + public function account() { return $this->belongsTo(Account::class); diff --git a/app/Models/CompanyUser.php b/app/Models/CompanyUser.php index 546890ab8f2b..4ee4a3be4354 100644 --- a/app/Models/CompanyUser.php +++ b/app/Models/CompanyUser.php @@ -25,6 +25,9 @@ class CompanyUser extends Pivot protected $casts = [ 'settings' => 'object', 'permissions' => 'object', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; public function account() diff --git a/app/Models/Country.php b/app/Models/Country.php index 1578db2874b2..139f07ab468d 100644 --- a/app/Models/Country.php +++ b/app/Models/Country.php @@ -21,6 +21,9 @@ class Country extends StaticModel 'eea' => 'boolean', 'swap_postal_code' => 'boolean', 'swap_currency_symbol' => 'boolean', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; /** diff --git a/app/Models/Currency.php b/app/Models/Currency.php index 79c4bfd04e1b..c9636390f166 100644 --- a/app/Models/Currency.php +++ b/app/Models/Currency.php @@ -19,6 +19,9 @@ class Currency extends StaticModel protected $casts = [ 'swap_currency_symbol' => 'boolean', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; } diff --git a/app/Models/Gateway.php b/app/Models/Gateway.php index 1cc1dd03e772..32d6bcda6a36 100644 --- a/app/Models/Gateway.php +++ b/app/Models/Gateway.php @@ -20,6 +20,9 @@ class Gateway extends StaticModel protected $casts = [ 'is_offsite' => 'boolean', 'is_secure' => 'boolean', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; /** diff --git a/app/Models/GroupSetting.php b/app/Models/GroupSetting.php index 7714b5bccee3..e01b6539050a 100644 --- a/app/Models/GroupSetting.php +++ b/app/Models/GroupSetting.php @@ -26,7 +26,10 @@ class GroupSetting extends StaticModel public $timestamps = false; protected $casts = [ - 'settings' => 'object' + 'settings' => 'object', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; public function company() diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 8cc21253b92e..c377db18faff 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -78,7 +78,10 @@ class Invoice extends BaseModel protected $casts = [ 'settings' => 'object', - 'line_items' => 'object' + 'line_items' => 'object', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; protected $with = [ diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 08953ffbea75..91d808e39646 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -52,7 +52,10 @@ class Payment extends BaseModel ]; protected $casts = [ - 'settings' => 'object' + 'settings' => 'object', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; public function client() diff --git a/app/Models/PaymentLibrary.php b/app/Models/PaymentLibrary.php index 28cb2cdf9440..2a31a5960dd6 100644 --- a/app/Models/PaymentLibrary.php +++ b/app/Models/PaymentLibrary.php @@ -21,6 +21,9 @@ class PaymentLibrary extends BaseModel protected $casts = [ 'visible' => 'boolean', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; /** diff --git a/app/Models/Quote.php b/app/Models/Quote.php index a6bd9cbbe2c4..92fd4c833224 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -48,7 +48,10 @@ class Quote extends BaseModel ]; protected $casts = [ - 'settings' => 'object' + 'settings' => 'object', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; const STATUS_DRAFT = 1; diff --git a/app/Models/RecurringInvoice.php b/app/Models/RecurringInvoice.php index 4c8808361c3c..551a7d16cc72 100644 --- a/app/Models/RecurringInvoice.php +++ b/app/Models/RecurringInvoice.php @@ -83,6 +83,9 @@ class RecurringInvoice extends BaseModel protected $casts = [ 'settings' => 'object', 'line_items' => 'object', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; protected $appends = [ diff --git a/app/Models/RecurringQuote.php b/app/Models/RecurringQuote.php index cd1ef681184e..75ccffbab956 100644 --- a/app/Models/RecurringQuote.php +++ b/app/Models/RecurringQuote.php @@ -79,7 +79,10 @@ class RecurringQuote extends BaseModel ]; protected $casts = [ - 'settings' => 'object' + 'settings' => 'object', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; protected $with = [ diff --git a/app/Models/StaticModel.php b/app/Models/StaticModel.php index 54d2d6bf32c2..e3784fca6bf6 100644 --- a/app/Models/StaticModel.php +++ b/app/Models/StaticModel.php @@ -16,6 +16,12 @@ use Illuminate\Database\Eloquent\Model; class StaticModel extends Model { + protected $casts = [ + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', + ]; + public function getIdAttribute() { return (string)$this->attributes['id']; diff --git a/app/Models/User.php b/app/Models/User.php index 1cb8ea6b7681..cbbbccf639e7 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -52,11 +52,6 @@ class User extends Authenticatable implements MustVerifyEmail protected $appends = [ 'hashed_id' ]; - - public function getHashedIdAttribute() - { - return $this->encodePrimaryKey($this->id); - } /** * The attributes that are mass assignable. @@ -91,8 +86,16 @@ class User extends Authenticatable implements MustVerifyEmail protected $casts = [ 'settings' => 'object', 'permissions' => 'object', + 'updated_at' => 'timestamp', + 'created_at' => 'timestamp', + 'deleted_at' => 'timestamp', ]; + public function getHashedIdAttribute() + { + return $this->encodePrimaryKey($this->id); + } + /** * Returns a account. * diff --git a/tests/Feature/ClientModelTest.php b/tests/Feature/ClientModelTest.php index 09ab6fae10e1..e9db3c9c73b3 100644 --- a/tests/Feature/ClientModelTest.php +++ b/tests/Feature/ClientModelTest.php @@ -62,14 +62,14 @@ class ClientModelTest extends TestCase foreach($gateway->driver($this->client)->gatewayTypes() as $type) $payment_methods[] = [$gateway->id => $type]; - $this->assertEquals(10, count($payment_methods)); + $this->assertEquals(8, count($payment_methods)); $payment_methods_collections = collect($payment_methods); //** Plucks the remaining keys into its own collection $payment_methods_intersect = $payment_methods_collections->intersectByKeys( $payment_methods_collections->flatten(1)->unique() ); - $this->assertEquals(5, $payment_methods_intersect->count()); + $this->assertEquals(4, $payment_methods_intersect->count()); $payment_urls = []; @@ -95,7 +95,7 @@ class ClientModelTest extends TestCase } - $this->assertEquals(5, count($payment_urls)); + $this->assertEquals(4, count($payment_urls)); }