mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
cast created_at/updated_at/deleted_at to timestamps
This commit is contained in:
parent
2c05f5a47e
commit
1778e63421
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -22,6 +22,9 @@ class ClientGatewayToken extends BaseModel
|
||||
|
||||
protected $casts = [
|
||||
'meta' => 'object',
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
'deleted_at' => 'timestamp',
|
||||
];
|
||||
|
||||
public function client()
|
||||
|
@ -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 = [
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
|
@ -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',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -19,6 +19,9 @@ class Currency extends StaticModel
|
||||
|
||||
protected $casts = [
|
||||
'swap_currency_symbol' => 'boolean',
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
'deleted_at' => 'timestamp',
|
||||
];
|
||||
|
||||
}
|
||||
|
@ -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',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -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()
|
||||
|
@ -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 = [
|
||||
|
@ -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()
|
||||
|
@ -21,6 +21,9 @@ class PaymentLibrary extends BaseModel
|
||||
|
||||
protected $casts = [
|
||||
'visible' => 'boolean',
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
'deleted_at' => 'timestamp',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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 = [
|
||||
|
@ -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 = [
|
||||
|
@ -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'];
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user