Convert deprecated $dates property to $casts

This commit is contained in:
Laravel Shift 2021-06-10 20:17:18 +00:00
parent bdf23e472e
commit 9f43ce97e9
17 changed files with 31 additions and 47 deletions

View file

@ -21,11 +21,10 @@ class Accessory extends SnipeModel
use Loggable, Presentable; use Loggable, Presentable;
use SoftDeletes; use SoftDeletes;
protected $dates = ['deleted_at', 'purchase_date'];
protected $table = 'accessories'; protected $table = 'accessories';
protected $casts = [ protected $casts = [
'requestable' => 'boolean', 'purchase_date' => 'datetime',
]; 'requestable' => 'boolean', ];
use Searchable; use Searchable;
use Acceptable; use Acceptable;

View file

@ -19,7 +19,7 @@ class Actionlog extends SnipeModel
protected $presenter = \App\Presenters\ActionlogPresenter::class; protected $presenter = \App\Presenters\ActionlogPresenter::class;
use SoftDeletes; use SoftDeletes;
use Presentable; use Presentable;
protected $dates = ['deleted_at'];
protected $table = 'action_logs'; protected $table = 'action_logs';
public $timestamps = true; public $timestamps = true;

View file

@ -66,18 +66,14 @@ class Asset extends Depreciable
protected $injectUniqueIdentifier = true; protected $injectUniqueIdentifier = true;
// We set these as protected dates so that they will be easily accessible via Carbon // We set these as protected dates so that they will be easily accessible via Carbon
protected $dates = [
'created_at',
'updated_at',
'deleted_at',
'purchase_date',
'last_checkout',
'expected_checkin',
'last_audit_date',
'next_audit_date',
];
protected $casts = [ protected $casts = [
'purchase_date' => 'datetime',
'last_checkout' => 'datetime',
'expected_checkin' => 'datetime',
'last_audit_date' => 'datetime',
'next_audit_date' => 'datetime',
'model_id' => 'integer', 'model_id' => 'integer',
'status_id' => 'integer', 'status_id' => 'integer',
'company_id' => 'integer', 'company_id' => 'integer',

View file

@ -18,8 +18,10 @@ class AssetMaintenance extends Model implements ICompanyableChild
use SoftDeletes; use SoftDeletes;
use CompanyableChildTrait; use CompanyableChildTrait;
use ValidatingTrait; use ValidatingTrait;
protected $casts = [
protected $dates = ['deleted_at', 'start_date', 'completion_date']; 'start_date' => 'datetime',
'completion_date' => 'datetime',
];
protected $table = 'asset_maintenances'; protected $table = 'asset_maintenances';
protected $rules = [ protected $rules = [
'asset_id' => 'required|integer', 'asset_id' => 'required|integer',

View file

@ -19,7 +19,7 @@ class AssetModel extends SnipeModel
use SoftDeletes; use SoftDeletes;
protected $presenter = \App\Presenters\AssetModelPresenter::class; protected $presenter = \App\Presenters\AssetModelPresenter::class;
use Requestable, Presentable; use Requestable, Presentable;
protected $dates = ['deleted_at'];
protected $table = 'models'; protected $table = 'models';
protected $hidden = ['user_id', 'deleted_at']; protected $hidden = ['user_id', 'deleted_at'];

View file

@ -22,7 +22,7 @@ class Category extends SnipeModel
protected $presenter = \App\Presenters\CategoryPresenter::class; protected $presenter = \App\Presenters\CategoryPresenter::class;
use Presentable; use Presentable;
use SoftDeletes; use SoftDeletes;
protected $dates = ['deleted_at'];
protected $table = 'categories'; protected $table = 'categories';
protected $hidden = ['user_id', 'deleted_at']; protected $hidden = ['user_id', 'deleted_at'];

View file

@ -10,15 +10,9 @@ class CheckoutAcceptance extends Model
{ {
use SoftDeletes; use SoftDeletes;
/** protected $casts = [
* The attributes that should be mutated to dates. 'accepted_at' => 'datetime',
* 'declined_at' => 'datetime',
* @var array
*/
protected $dates = [
'accepted_at',
'declined_at',
'deleted_at',
]; ];
/** /**

View file

@ -18,8 +18,9 @@ class Component extends SnipeModel
use CompanyableTrait; use CompanyableTrait;
use Loggable, Presentable; use Loggable, Presentable;
use SoftDeletes; use SoftDeletes;
protected $casts = [
protected $dates = ['deleted_at', 'purchase_date']; 'purchase_date' => 'datetime',
];
protected $table = 'components'; protected $table = 'components';
/** /**

View file

@ -17,15 +17,14 @@ class Consumable extends SnipeModel
use SoftDeletes; use SoftDeletes;
use Acceptable; use Acceptable;
protected $dates = ['deleted_at', 'purchase_date'];
protected $table = 'consumables'; protected $table = 'consumables';
protected $casts = [ protected $casts = [
'purchase_date' => 'datetime',
'requestable' => 'boolean', 'requestable' => 'boolean',
'category_id' => 'integer', 'category_id' => 'integer',
'company_id' => 'integer', 'company_id' => 'integer',
'qty' => 'integer', 'qty' => 'integer',
'min_amt' => 'integer', 'min_amt' => 'integer', ];
];
/** /**
* Category validation rules * Category validation rules

View file

@ -8,7 +8,6 @@ class ConsumableAssignment extends Model
{ {
use CompanyableTrait; use CompanyableTrait;
protected $dates = ['deleted_at'];
protected $table = 'consumables_users'; protected $table = 'consumables_users';
public function consumable() public function consumable()

View file

@ -22,14 +22,7 @@ class License extends Depreciable
use ValidatingTrait; use ValidatingTrait;
// We set these as protected dates so that they will be easily accessible via Carbon // We set these as protected dates so that they will be easily accessible via Carbon
protected $dates = [
'created_at',
'updated_at',
'deleted_at',
'purchase_date',
'expiration_date',
'termination_date',
];
public $timestamps = true; public $timestamps = true;
@ -37,6 +30,9 @@ class License extends Depreciable
protected $table = 'licenses'; protected $table = 'licenses';
protected $casts = [ protected $casts = [
'purchase_date' => 'datetime',
'expiration_date' => 'datetime',
'termination_date' => 'datetime',
'seats' => 'integer', 'seats' => 'integer',
'category_id' => 'integer', 'category_id' => 'integer',
'company_id' => 'integer', 'company_id' => 'integer',

View file

@ -17,7 +17,6 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild
protected $presenter = \App\Presenters\LicenseSeatPresenter::class; protected $presenter = \App\Presenters\LicenseSeatPresenter::class;
use Presentable; use Presentable;
protected $dates = ['deleted_at'];
protected $guarded = 'id'; protected $guarded = 'id';
protected $table = 'license_seats'; protected $table = 'license_seats';

View file

@ -19,7 +19,7 @@ class Location extends SnipeModel
protected $presenter = \App\Presenters\LocationPresenter::class; protected $presenter = \App\Presenters\LocationPresenter::class;
use Presentable; use Presentable;
use SoftDeletes; use SoftDeletes;
protected $dates = ['deleted_at'];
protected $table = 'locations'; protected $table = 'locations';
protected $rules = [ protected $rules = [
'name' => 'required|min:2|max:255|unique_undeleted', 'name' => 'required|min:2|max:255|unique_undeleted',

View file

@ -13,7 +13,7 @@ class Manufacturer extends SnipeModel
protected $presenter = \App\Presenters\ManufacturerPresenter::class; protected $presenter = \App\Presenters\ManufacturerPresenter::class;
use Presentable; use Presentable;
use SoftDeletes; use SoftDeletes;
protected $dates = ['deleted_at'];
protected $table = 'manufacturers'; protected $table = 'manufacturers';
// Declare the rules for the form validation // Declare the rules for the form validation

View file

@ -14,7 +14,7 @@ class Statuslabel extends SnipeModel
use UniqueUndeletedTrait; use UniqueUndeletedTrait;
protected $injectUniqueIdentifier = true; protected $injectUniqueIdentifier = true;
protected $dates = ['deleted_at'];
protected $table = 'status_labels'; protected $table = 'status_labels';
protected $hidden = ['user_id', 'deleted_at']; protected $hidden = ['user_id', 'deleted_at'];

View file

@ -10,7 +10,7 @@ use Watson\Validating\ValidatingTrait;
class Supplier extends SnipeModel class Supplier extends SnipeModel
{ {
use SoftDeletes; use SoftDeletes;
protected $dates = ['deleted_at'];
protected $table = 'suppliers'; protected $table = 'suppliers';
protected $rules = [ protected $rules = [

View file

@ -29,7 +29,6 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
use Presentable; use Presentable;
use Searchable; use Searchable;
protected $dates = ['deleted_at'];
protected $hidden = ['password', 'remember_token', 'permissions', 'reset_password_code', 'persist_code']; protected $hidden = ['password', 'remember_token', 'permissions', 'reset_password_code', 'persist_code'];
protected $table = 'users'; protected $table = 'users';
protected $injectUniqueIdentifier = true; protected $injectUniqueIdentifier = true;