cast created_at/updated_at/deleted_at to timestamps

This commit is contained in:
David Bomba 2019-09-26 08:27:26 +10:00
parent 2c05f5a47e
commit 1778e63421
21 changed files with 87 additions and 15 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -22,6 +22,9 @@ class ClientGatewayToken extends BaseModel
protected $casts = [
'meta' => 'object',
'updated_at' => 'timestamp',
'created_at' => 'timestamp',
'deleted_at' => 'timestamp',
];
public function client()

View File

@ -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 = [

View File

@ -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()
{

View File

@ -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);

View File

@ -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()

View File

@ -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',
];
/**

View File

@ -19,6 +19,9 @@ class Currency extends StaticModel
protected $casts = [
'swap_currency_symbol' => 'boolean',
'updated_at' => 'timestamp',
'created_at' => 'timestamp',
'deleted_at' => 'timestamp',
];
}

View File

@ -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',
];
/**

View File

@ -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()

View File

@ -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 = [

View File

@ -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()

View File

@ -21,6 +21,9 @@ class PaymentLibrary extends BaseModel
protected $casts = [
'visible' => 'boolean',
'updated_at' => 'timestamp',
'created_at' => 'timestamp',
'deleted_at' => 'timestamp',
];
/**

View File

@ -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;

View File

@ -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 = [

View File

@ -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 = [

View File

@ -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'];

View File

@ -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.
*

View File

@ -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));
}