diff --git a/app/Console/Commands/FixDoubleEscape.php b/app/Console/Commands/FixDoubleEscape.php index 13a1d3b9b5..42a1765913 100644 --- a/app/Console/Commands/FixDoubleEscape.php +++ b/app/Console/Commands/FixDoubleEscape.php @@ -38,21 +38,21 @@ class FixDoubleEscape extends Command public function handle() { $tables = [ - '\App\Models\Asset' => ['name'], - '\App\Models\License' => ['name'], - '\App\Models\Consumable' => ['name'], - '\App\Models\Accessory' => ['name'], - '\App\Models\Component' => ['name'], - '\App\Models\Company' => ['name'], - '\App\Models\Manufacturer' => ['name'], - '\App\Models\Supplier' => ['name'], - '\App\Models\Statuslabel' => ['name'], - '\App\Models\Depreciation' => ['name'], - '\App\Models\AssetModel' => ['name'], - '\App\Models\Group' => ['name'], - '\App\Models\Department' => ['name'], - '\App\Models\Location' => ['name'], - '\App\Models\User' => ['first_name', 'last_name'], + \App\Models\Asset::class => ['name'], + \App\Models\License::class => ['name'], + \App\Models\Consumable::class => ['name'], + \App\Models\Accessory::class => ['name'], + \App\Models\Component::class => ['name'], + \App\Models\Company::class => ['name'], + \App\Models\Manufacturer::class => ['name'], + \App\Models\Supplier::class => ['name'], + \App\Models\Statuslabel::class => ['name'], + \App\Models\Depreciation::class => ['name'], + \App\Models\AssetModel::class => ['name'], + \App\Models\Group::class => ['name'], + \App\Models\Department::class => ['name'], + \App\Models\Location::class => ['name'], + \App\Models\User::class => ['first_name', 'last_name'], ]; $count = []; diff --git a/app/Console/Commands/FixMismatchedAssetsAndLogs.php b/app/Console/Commands/FixMismatchedAssetsAndLogs.php index 47729f8c30..34b6b3edfc 100644 --- a/app/Console/Commands/FixMismatchedAssetsAndLogs.php +++ b/app/Console/Commands/FixMismatchedAssetsAndLogs.php @@ -56,19 +56,19 @@ class FixMismatchedAssetsAndLogs extends Command $mismatch_count = 0; $assets = Asset::whereNotNull('assigned_to') - ->where('assigned_type', '=', 'App\\Models\\User') + ->where('assigned_type', '=', \App\Models\User::class) ->orderBy('id', 'ASC')->get(); foreach ($assets as $asset) { // get the last checkout of the asset - if ($checkout_log = Actionlog::where('target_type', '=', 'App\\Models\\User') + if ($checkout_log = Actionlog::where('target_type', '=', \App\Models\User::class) ->where('action_type', '=', 'checkout') ->where('item_id', '=', $asset->id) ->orderBy('created_at', 'DESC') ->first()) { // Now check for a subsequent checkin log - we want to ignore those - if (! $checkin_log = Actionlog::where('target_type', '=', 'App\\Models\\User') + if (! $checkin_log = Actionlog::where('target_type', '=', \App\Models\User::class) ->where('action_type', '=', 'checkin from') ->where('item_id', '=', $asset->id) ->whereDate('created_at', '>', $checkout_log->created_at) diff --git a/app/Console/Commands/SyncAssetLocations.php b/app/Console/Commands/SyncAssetLocations.php index e7aae9991e..f510176bce 100644 --- a/app/Console/Commands/SyncAssetLocations.php +++ b/app/Console/Commands/SyncAssetLocations.php @@ -57,7 +57,7 @@ class SyncAssetLocations extends Command $bar->advance(); } - $assigned_user_assets = Asset::where('assigned_type', 'App\Models\User')->whereNotNull('assigned_to')->whereNull('deleted_at')->get(); + $assigned_user_assets = Asset::where('assigned_type', \App\Models\User::class)->whereNotNull('assigned_to')->whereNull('deleted_at')->get(); $output['info'][] = 'There are '.$assigned_user_assets->count().' assets checked out to users.'; foreach ($assigned_user_assets as $assigned_user_asset) { if (($assigned_user_asset->assignedTo) && ($assigned_user_asset->assignedTo->userLoc)) { @@ -73,7 +73,7 @@ class SyncAssetLocations extends Command $bar->advance(); } - $assigned_location_assets = Asset::where('assigned_type', 'App\Models\Location') + $assigned_location_assets = Asset::where('assigned_type', \App\Models\Location::class) ->whereNotNull('assigned_to')->whereNull('deleted_at')->get(); $output['info'][] = 'There are '.$assigned_location_assets->count().' assets checked out to locations.'; @@ -90,7 +90,7 @@ class SyncAssetLocations extends Command } // Assigned to assets - $assigned_asset_assets = Asset::where('assigned_type', 'App\Models\Asset') + $assigned_asset_assets = Asset::where('assigned_type', \App\Models\Asset::class) ->whereNotNull('assigned_to')->whereNull('deleted_at')->get(); $output['info'][] = 'Asset-assigned assets: '.$assigned_asset_assets->count(); diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 3ad544a785..a3c2bcd2ca 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -577,7 +577,7 @@ class AssetsController extends Controller } elseif (($request->filled('assigned_asset')) && ($target = Asset::find($request->get('assigned_asset')))) { $location = $target->location_id; - Asset::where('assigned_type', '\\App\\Models\\Asset')->where('assigned_to', $id) + Asset::where('assigned_type', \App\Models\Asset::class)->where('assigned_to', $id) ->update(['location_id' => $target->location_id]); } elseif (($request->filled('assigned_location')) && ($target = Location::find($request->get('assigned_location')))) { $location = $target->id; diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index be0b84a5c9..c514bb531e 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -914,7 +914,7 @@ class ReportsController extends Controller $assetsForReport = $acceptances ->filter(function ($acceptance) { - return $acceptance->checkoutable_type == 'App\Models\Asset'; + return $acceptance->checkoutable_type == \App\Models\Asset::class; }) ->map(function ($acceptance) { return $acceptance->checkoutable; diff --git a/app/Http/Controllers/Users/BulkUsersController.php b/app/Http/Controllers/Users/BulkUsersController.php index fc02753e74..9f41448d3b 100644 --- a/app/Http/Controllers/Users/BulkUsersController.php +++ b/app/Http/Controllers/Users/BulkUsersController.php @@ -166,7 +166,7 @@ class BulkUsersController extends Controller } $users = User::whereIn('id', $user_raw_array)->get(); - $assets = Asset::whereIn('assigned_to', $user_raw_array)->where('assigned_type', 'App\Models\User')->get(); + $assets = Asset::whereIn('assigned_to', $user_raw_array)->where('assigned_type', \App\Models\User::class)->get(); $accessories = DB::table('accessories_users')->whereIn('assigned_to', $user_raw_array)->get(); $licenses = DB::table('license_seats')->whereIn('assigned_to', $user_raw_array)->get(); diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index bc7c2a2da5..018624d22f 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -125,7 +125,7 @@ class UsersController extends Controller $user->permissions = json_encode($permissions_array); // we have to invoke the - app('App\Http\Requests\ImageUploadRequest')->handleImages($user, 600, 'image', 'avatars', 'avatar'); + app(\App\Http\Requests\ImageUploadRequest::class)->handleImages($user, 600, 'image', 'avatars', 'avatar'); if ($user->save()) { if ($request->filled('groups')) { @@ -289,7 +289,7 @@ class UsersController extends Controller $user->permissions = json_encode($permissions_array); // Handle uploaded avatar - app('App\Http\Requests\ImageUploadRequest')->handleImages($user, 600, 'avatar', 'avatars', 'avatar'); + app(\App\Http\Requests\ImageUploadRequest::class)->handleImages($user, 600, 'avatar', 'avatars', 'avatar'); //\Log::debug(print_r($user, true)); diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index 2baacbfaa8..ad8c127398 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -200,12 +200,12 @@ class CheckoutableListener public function subscribe($events) { $events->listen( - 'App\Events\CheckoutableCheckedIn', + \App\Events\CheckoutableCheckedIn::class, 'App\Listeners\CheckoutableListener@onCheckedIn' ); $events->listen( - 'App\Events\CheckoutableCheckedOut', + \App\Events\CheckoutableCheckedOut::class, 'App\Listeners\CheckoutableListener@onCheckedOut' ); } diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php index c201ce07b5..c2e5399d29 100755 --- a/app/Models/Accessory.php +++ b/app/Models/Accessory.php @@ -16,7 +16,7 @@ use Watson\Validating\ValidatingTrait; */ class Accessory extends SnipeModel { - protected $presenter = 'App\Presenters\AccessoryPresenter'; + protected $presenter = \App\Presenters\AccessoryPresenter::class; use CompanyableTrait; use Loggable, Presentable; use SoftDeletes; @@ -102,7 +102,7 @@ class Accessory extends SnipeModel */ public function supplier() { - return $this->belongsTo('\App\Models\Supplier', 'supplier_id'); + return $this->belongsTo(\App\Models\Supplier::class, 'supplier_id'); } /** @@ -130,7 +130,7 @@ class Accessory extends SnipeModel */ public function company() { - return $this->belongsTo('\App\Models\Company', 'company_id'); + return $this->belongsTo(\App\Models\Company::class, 'company_id'); } /** @@ -142,7 +142,7 @@ class Accessory extends SnipeModel */ public function location() { - return $this->belongsTo('\App\Models\Location', 'location_id'); + return $this->belongsTo(\App\Models\Location::class, 'location_id'); } /** @@ -154,7 +154,7 @@ class Accessory extends SnipeModel */ public function category() { - return $this->belongsTo('\App\Models\Category', 'category_id')->where('category_type', '=', 'accessory'); + return $this->belongsTo(\App\Models\Category::class, 'category_id')->where('category_type', '=', 'accessory'); } /** @@ -166,7 +166,7 @@ class Accessory extends SnipeModel */ public function assetlog() { - return $this->hasMany('\App\Models\Actionlog', 'item_id')->where('item_type', self::class)->orderBy('created_at', 'desc')->withTrashed(); + return $this->hasMany(\App\Models\Actionlog::class, 'item_id')->where('item_type', self::class)->orderBy('created_at', 'desc')->withTrashed(); } /** @@ -228,7 +228,7 @@ class Accessory extends SnipeModel */ public function users() { - return $this->belongsToMany('\App\Models\User', 'accessories_users', 'accessory_id', 'assigned_to')->withPivot('id', 'created_at', 'note')->withTrashed(); + return $this->belongsToMany(\App\Models\User::class, 'accessories_users', 'accessory_id', 'assigned_to')->withPivot('id', 'created_at', 'note')->withTrashed(); } /** @@ -240,7 +240,7 @@ class Accessory extends SnipeModel */ public function hasUsers() { - return $this->belongsToMany('\App\Models\User', 'accessories_users', 'accessory_id', 'assigned_to')->count(); + return $this->belongsToMany(\App\Models\User::class, 'accessories_users', 'accessory_id', 'assigned_to')->count(); } /** @@ -252,7 +252,7 @@ class Accessory extends SnipeModel */ public function manufacturer() { - return $this->belongsTo('\App\Models\Manufacturer', 'manufacturer_id'); + return $this->belongsTo(\App\Models\Manufacturer::class, 'manufacturer_id'); } /** diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.php index b1f0cddb4c..3ac8c5cc7c 100755 --- a/app/Models/Actionlog.php +++ b/app/Models/Actionlog.php @@ -16,7 +16,7 @@ use Illuminate\Support\Facades\Auth; */ class Actionlog extends SnipeModel { - protected $presenter = "App\Presenters\ActionlogPresenter"; + protected $presenter = \App\Presenters\ActionlogPresenter::class; use SoftDeletes; use Presentable; protected $dates = ['deleted_at']; @@ -88,7 +88,7 @@ class Actionlog extends SnipeModel */ public function company() { - return $this->hasMany('\App\Models\Company', 'id', 'company_id'); + return $this->hasMany(\App\Models\Company::class, 'id', 'company_id'); } /** @@ -183,7 +183,7 @@ class Actionlog extends SnipeModel */ public function location() { - return $this->belongsTo('\App\Models\Location', 'location_id')->withTrashed(); + return $this->belongsTo(\App\Models\Location::class, 'location_id')->withTrashed(); } /** diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 26c3a0a4ed..999c6711cb 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -26,7 +26,7 @@ use Watson\Validating\ValidatingTrait; */ class Asset extends Depreciable { - protected $presenter = 'App\Presenters\AssetPresenter'; + protected $presenter = \App\Presenters\AssetPresenter::class; use Loggable, Requestable, Presentable, SoftDeletes, ValidatingTrait, UniqueUndeletedTrait, UniqueSerialTrait; const LOCATION = 'location'; @@ -224,7 +224,7 @@ class Asset extends Depreciable */ public function company() { - return $this->belongsTo('\App\Models\Company', 'company_id'); + return $this->belongsTo(\App\Models\Company::class, 'company_id'); } /** @@ -304,7 +304,7 @@ class Asset extends Depreciable if ($this->save()) { if (is_int($admin)) { $checkedOutBy = User::findOrFail($admin); - } elseif (get_class($admin) === 'App\Models\User') { + } elseif (get_class($admin) === \App\Models\User::class) { $checkedOutBy = $admin; } else { $checkedOutBy = Auth::user(); @@ -358,7 +358,7 @@ class Asset extends Depreciable */ public function depreciation() { - return $this->model->belongsTo('\App\Models\Depreciation', 'depreciation_id'); + return $this->model->belongsTo(\App\Models\Depreciation::class, 'depreciation_id'); } /** @@ -370,7 +370,7 @@ class Asset extends Depreciable */ public function components() { - return $this->belongsToMany('\App\Models\Component', 'components_assets', 'asset_id', 'component_id')->withPivot('id', 'assigned_qty')->withTrashed(); + return $this->belongsToMany(\App\Models\Component::class, 'components_assets', 'asset_id', 'component_id')->withPivot('id', 'assigned_qty')->withTrashed(); } /** @@ -398,7 +398,7 @@ class Asset extends Depreciable */ public function uploads() { - return $this->hasMany('\App\Models\Actionlog', 'item_id') + return $this->hasMany(\App\Models\Actionlog::class, 'item_id') ->where('item_type', '=', self::class) ->where('action_type', '=', 'uploaded') ->whereNotNull('filename') @@ -443,7 +443,7 @@ class Asset extends Depreciable */ public function assignedAssets() { - return $this->morphMany('App\Models\Asset', 'assigned', 'assigned_type', 'assigned_to')->withTrashed(); + return $this->morphMany(\App\Models\Asset::class, 'assigned', 'assigned_type', 'assigned_to')->withTrashed(); } /** @@ -508,7 +508,7 @@ class Asset extends Depreciable */ public function defaultLoc() { - return $this->belongsTo('\App\Models\Location', 'rtd_location_id'); + return $this->belongsTo(\App\Models\Location::class, 'rtd_location_id'); } /** @@ -541,7 +541,7 @@ class Asset extends Depreciable */ public function assetlog() { - return $this->hasMany('\App\Models\Actionlog', 'item_id') + return $this->hasMany(\App\Models\Actionlog::class, 'item_id') ->where('item_type', '=', self::class) ->orderBy('created_at', 'desc') ->withTrashed(); @@ -600,7 +600,7 @@ class Asset extends Depreciable */ public function assetmaintenances() { - return $this->hasMany('\App\Models\AssetMaintenance', 'asset_id') + return $this->hasMany(\App\Models\AssetMaintenance::class, 'asset_id') ->orderBy('created_at', 'desc'); } @@ -613,7 +613,7 @@ class Asset extends Depreciable */ public function adminuser() { - return $this->belongsTo('\App\Models\User', 'user_id'); + return $this->belongsTo(\App\Models\User::class, 'user_id'); } /** @@ -625,7 +625,7 @@ class Asset extends Depreciable */ public function assetstatus() { - return $this->belongsTo('\App\Models\Statuslabel', 'status_id'); + return $this->belongsTo(\App\Models\Statuslabel::class, 'status_id'); } /** @@ -637,7 +637,7 @@ class Asset extends Depreciable */ public function model() { - return $this->belongsTo('\App\Models\AssetModel', 'model_id')->withTrashed(); + return $this->belongsTo(\App\Models\AssetModel::class, 'model_id')->withTrashed(); } /** @@ -670,7 +670,7 @@ class Asset extends Depreciable */ public function licenses() { - return $this->belongsToMany('\App\Models\License', 'license_seats', 'asset_id', 'license_id'); + return $this->belongsToMany(\App\Models\License::class, 'license_seats', 'asset_id', 'license_id'); } /** @@ -682,7 +682,7 @@ class Asset extends Depreciable */ public function licenseseats() { - return $this->hasMany('\App\Models\LicenseSeat', 'asset_id'); + return $this->hasMany(\App\Models\LicenseSeat::class, 'asset_id'); } /** @@ -694,7 +694,7 @@ class Asset extends Depreciable */ public function supplier() { - return $this->belongsTo('\App\Models\Supplier', 'supplier_id'); + return $this->belongsTo(\App\Models\Supplier::class, 'supplier_id'); } /** @@ -706,7 +706,7 @@ class Asset extends Depreciable */ public function location() { - return $this->belongsTo('\App\Models\Location', 'location_id'); + return $this->belongsTo(\App\Models\Location::class, 'location_id'); } /** diff --git a/app/Models/AssetMaintenance.php b/app/Models/AssetMaintenance.php index d88a968fc6..d501f42361 100644 --- a/app/Models/AssetMaintenance.php +++ b/app/Models/AssetMaintenance.php @@ -129,7 +129,7 @@ class AssetMaintenance extends Model implements ICompanyableChild */ public function asset() { - return $this->belongsTo('\App\Models\Asset', 'asset_id') + return $this->belongsTo(\App\Models\Asset::class, 'asset_id') ->withTrashed(); } @@ -142,13 +142,13 @@ class AssetMaintenance extends Model implements ICompanyableChild */ public function admin() { - return $this->belongsTo('\App\Models\User', 'user_id') + return $this->belongsTo(\App\Models\User::class, 'user_id') ->withTrashed(); } public function supplier() { - return $this->belongsTo('\App\Models\Supplier', 'supplier_id') + return $this->belongsTo(\App\Models\Supplier::class, 'supplier_id') ->withTrashed(); } diff --git a/app/Models/AssetModel.php b/app/Models/AssetModel.php index acb50b5879..377be0f9c8 100755 --- a/app/Models/AssetModel.php +++ b/app/Models/AssetModel.php @@ -17,7 +17,7 @@ use Watson\Validating\ValidatingTrait; class AssetModel extends SnipeModel { use SoftDeletes; - protected $presenter = 'App\Presenters\AssetModelPresenter'; + protected $presenter = \App\Presenters\AssetModelPresenter::class; use Requestable, Presentable; protected $dates = ['deleted_at']; protected $table = 'models'; @@ -98,7 +98,7 @@ class AssetModel extends SnipeModel */ public function assets() { - return $this->hasMany('\App\Models\Asset', 'model_id'); + return $this->hasMany(\App\Models\Asset::class, 'model_id'); } /** @@ -110,7 +110,7 @@ class AssetModel extends SnipeModel */ public function category() { - return $this->belongsTo('\App\Models\Category', 'category_id'); + return $this->belongsTo(\App\Models\Category::class, 'category_id'); } /** @@ -122,7 +122,7 @@ class AssetModel extends SnipeModel */ public function depreciation() { - return $this->belongsTo('\App\Models\Depreciation', 'depreciation_id'); + return $this->belongsTo(\App\Models\Depreciation::class, 'depreciation_id'); } /** @@ -134,7 +134,7 @@ class AssetModel extends SnipeModel */ public function manufacturer() { - return $this->belongsTo('\App\Models\Manufacturer', 'manufacturer_id'); + return $this->belongsTo(\App\Models\Manufacturer::class, 'manufacturer_id'); } /** @@ -146,7 +146,7 @@ class AssetModel extends SnipeModel */ public function fieldset() { - return $this->belongsTo('\App\Models\CustomFieldset', 'fieldset_id'); + return $this->belongsTo(\App\Models\CustomFieldset::class, 'fieldset_id'); } /** @@ -158,7 +158,7 @@ class AssetModel extends SnipeModel */ public function defaultValues() { - return $this->belongsToMany('\App\Models\CustomField', 'models_custom_fields')->withPivot('default_value'); + return $this->belongsToMany(\App\Models\CustomField::class, 'models_custom_fields')->withPivot('default_value'); } /** diff --git a/app/Models/Category.php b/app/Models/Category.php index 31726ee0d5..d19b013827 100755 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -19,7 +19,7 @@ use Watson\Validating\ValidatingTrait; */ class Category extends SnipeModel { - protected $presenter = 'App\Presenters\CategoryPresenter'; + protected $presenter = \App\Presenters\CategoryPresenter::class; use Presentable; use SoftDeletes; protected $dates = ['deleted_at']; @@ -105,7 +105,7 @@ class Category extends SnipeModel */ public function accessories() { - return $this->hasMany('\App\Models\Accessory'); + return $this->hasMany(\App\Models\Accessory::class); } /** @@ -117,7 +117,7 @@ class Category extends SnipeModel */ public function licenses() { - return $this->hasMany('\App\Models\License'); + return $this->hasMany(\App\Models\License::class); } /** @@ -129,7 +129,7 @@ class Category extends SnipeModel */ public function consumables() { - return $this->hasMany('\App\Models\Consumable'); + return $this->hasMany(\App\Models\Consumable::class); } /** @@ -141,7 +141,7 @@ class Category extends SnipeModel */ public function components() { - return $this->hasMany('\App\Models\Component'); + return $this->hasMany(\App\Models\Component::class); } /** @@ -178,7 +178,7 @@ class Category extends SnipeModel */ public function assets() { - return $this->hasManyThrough('\App\Models\Asset', '\App\Models\AssetModel', 'category_id', 'model_id'); + return $this->hasManyThrough(\App\Models\Asset::class, \App\Models\AssetModel::class, 'category_id', 'model_id'); } /** @@ -190,7 +190,7 @@ class Category extends SnipeModel */ public function models() { - return $this->hasMany('\App\Models\AssetModel', 'category_id'); + return $this->hasMany(\App\Models\AssetModel::class, 'category_id'); } /** diff --git a/app/Models/Company.php b/app/Models/Company.php index 373c623a32..e09c8472c7 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -23,7 +23,7 @@ final class Company extends SnipeModel 'name' => 'required|min:1|max:255|unique:companies,name', ]; - protected $presenter = 'App\Presenters\CompanyPresenter'; + protected $presenter = \App\Presenters\CompanyPresenter::class; use Presentable; /** diff --git a/app/Models/Component.php b/app/Models/Component.php index 5defd17d5e..7c413ea965 100644 --- a/app/Models/Component.php +++ b/app/Models/Component.php @@ -14,7 +14,7 @@ use Watson\Validating\ValidatingTrait; */ class Component extends SnipeModel { - protected $presenter = 'App\Presenters\ComponentPresenter'; + protected $presenter = \App\Presenters\ComponentPresenter::class; use CompanyableTrait; use Loggable, Presentable; use SoftDeletes; @@ -92,7 +92,7 @@ class Component extends SnipeModel */ public function location() { - return $this->belongsTo('\App\Models\Location', 'location_id'); + return $this->belongsTo(\App\Models\Location::class, 'location_id'); } /** @@ -104,7 +104,7 @@ class Component extends SnipeModel */ public function assets() { - return $this->belongsToMany('\App\Models\Asset', 'components_assets')->withPivot('id', 'assigned_qty', 'created_at', 'user_id'); + return $this->belongsToMany(\App\Models\Asset::class, 'components_assets')->withPivot('id', 'assigned_qty', 'created_at', 'user_id'); } /** @@ -118,7 +118,7 @@ class Component extends SnipeModel */ public function admin() { - return $this->belongsTo('\App\Models\User', 'user_id'); + return $this->belongsTo(\App\Models\User::class, 'user_id'); } /** @@ -130,7 +130,7 @@ class Component extends SnipeModel */ public function company() { - return $this->belongsTo('\App\Models\Company', 'company_id'); + return $this->belongsTo(\App\Models\Company::class, 'company_id'); } /** @@ -142,7 +142,7 @@ class Component extends SnipeModel */ public function category() { - return $this->belongsTo('\App\Models\Category', 'category_id'); + return $this->belongsTo(\App\Models\Category::class, 'category_id'); } /** @@ -154,7 +154,7 @@ class Component extends SnipeModel */ public function assetlog() { - return $this->hasMany('\App\Models\Actionlog', 'item_id')->where('item_type', self::class)->orderBy('created_at', 'desc')->withTrashed(); + return $this->hasMany(\App\Models\Actionlog::class, 'item_id')->where('item_type', self::class)->orderBy('created_at', 'desc')->withTrashed(); } /** diff --git a/app/Models/Consumable.php b/app/Models/Consumable.php index 3869ea68d3..b8a75a5c57 100644 --- a/app/Models/Consumable.php +++ b/app/Models/Consumable.php @@ -11,7 +11,7 @@ use Watson\Validating\ValidatingTrait; class Consumable extends SnipeModel { - protected $presenter = 'App\Presenters\ConsumablePresenter'; + protected $presenter = \App\Presenters\ConsumablePresenter::class; use CompanyableTrait; use Loggable, Presentable; use SoftDeletes; @@ -121,7 +121,7 @@ class Consumable extends SnipeModel */ public function admin() { - return $this->belongsTo('\App\Models\User', 'user_id'); + return $this->belongsTo(\App\Models\User::class, 'user_id'); } /** @@ -133,7 +133,7 @@ class Consumable extends SnipeModel */ public function consumableAssignments() { - return $this->hasMany('\App\Models\ConsumableAssignment'); + return $this->hasMany(\App\Models\ConsumableAssignment::class); } /** @@ -145,7 +145,7 @@ class Consumable extends SnipeModel */ public function company() { - return $this->belongsTo('\App\Models\Company', 'company_id'); + return $this->belongsTo(\App\Models\Company::class, 'company_id'); } /** @@ -157,7 +157,7 @@ class Consumable extends SnipeModel */ public function manufacturer() { - return $this->belongsTo('\App\Models\Manufacturer', 'manufacturer_id'); + return $this->belongsTo(\App\Models\Manufacturer::class, 'manufacturer_id'); } /** @@ -169,7 +169,7 @@ class Consumable extends SnipeModel */ public function location() { - return $this->belongsTo('\App\Models\Location', 'location_id'); + return $this->belongsTo(\App\Models\Location::class, 'location_id'); } /** @@ -181,7 +181,7 @@ class Consumable extends SnipeModel */ public function category() { - return $this->belongsTo('\App\Models\Category', 'category_id'); + return $this->belongsTo(\App\Models\Category::class, 'category_id'); } /** @@ -193,7 +193,7 @@ class Consumable extends SnipeModel */ public function assetlog() { - return $this->hasMany('\App\Models\Actionlog', 'item_id')->where('item_type', self::class)->orderBy('created_at', 'desc')->withTrashed(); + return $this->hasMany(\App\Models\Actionlog::class, 'item_id')->where('item_type', self::class)->orderBy('created_at', 'desc')->withTrashed(); } /** @@ -221,7 +221,7 @@ class Consumable extends SnipeModel */ public function users() { - return $this->belongsToMany('\App\Models\User', 'consumables_users', 'consumable_id', 'assigned_to')->withPivot('user_id')->withTrashed()->withTimestamps(); + return $this->belongsToMany(\App\Models\User::class, 'consumables_users', 'consumable_id', 'assigned_to')->withPivot('user_id')->withTrashed()->withTimestamps(); } /** diff --git a/app/Models/ConsumableAssignment.php b/app/Models/ConsumableAssignment.php index d82cbb5870..4c5ef53a60 100644 --- a/app/Models/ConsumableAssignment.php +++ b/app/Models/ConsumableAssignment.php @@ -13,16 +13,16 @@ class ConsumableAssignment extends Model public function consumable() { - return $this->belongsTo('\App\Models\Consumable'); + return $this->belongsTo(\App\Models\Consumable::class); } public function user() { - return $this->belongsTo('\App\Models\User', 'assigned_to'); + return $this->belongsTo(\App\Models\User::class, 'assigned_to'); } public function admin() { - return $this->belongsTo('\App\Models\User', 'user_id'); + return $this->belongsTo(\App\Models\User::class, 'user_id'); } } diff --git a/app/Models/CustomField.php b/app/Models/CustomField.php index 3185ebd2ce..01c85ab2c0 100644 --- a/app/Models/CustomField.php +++ b/app/Models/CustomField.php @@ -167,7 +167,7 @@ class CustomField extends Model */ public function fieldset() { - return $this->belongsToMany('\App\Models\CustomFieldset'); + return $this->belongsToMany(\App\Models\CustomFieldset::class); } /** @@ -179,7 +179,7 @@ class CustomField extends Model */ public function user() { - return $this->belongsTo('\App\Models\User'); + return $this->belongsTo(\App\Models\User::class); } /** @@ -191,7 +191,7 @@ class CustomField extends Model */ public function defaultValues() { - return $this->belongsToMany('\App\Models\AssetModel', 'models_custom_fields')->withPivot('default_value'); + return $this->belongsToMany(\App\Models\AssetModel::class, 'models_custom_fields')->withPivot('default_value'); } /** diff --git a/app/Models/CustomFieldset.php b/app/Models/CustomFieldset.php index f6f1e77cd5..83e91a4b31 100644 --- a/app/Models/CustomFieldset.php +++ b/app/Models/CustomFieldset.php @@ -38,7 +38,7 @@ class CustomFieldset extends Model */ public function fields() { - return $this->belongsToMany('\App\Models\CustomField')->withPivot(['required', 'order'])->orderBy('pivot_order'); + return $this->belongsToMany(\App\Models\CustomField::class)->withPivot(['required', 'order'])->orderBy('pivot_order'); } /** @@ -50,7 +50,7 @@ class CustomFieldset extends Model */ public function models() { - return $this->hasMany('\App\Models\AssetModel', 'fieldset_id'); + return $this->hasMany(\App\Models\AssetModel::class, 'fieldset_id'); } /** @@ -62,7 +62,7 @@ class CustomFieldset extends Model */ public function user() { - return $this->belongsTo('\App\Models\User'); //WARNING - not all CustomFieldsets have a User!! + return $this->belongsTo(\App\Models\User::class); //WARNING - not all CustomFieldsets have a User!! } /** diff --git a/app/Models/Department.php b/app/Models/Department.php index 1fd9567145..56be77115d 100644 --- a/app/Models/Department.php +++ b/app/Models/Department.php @@ -71,7 +71,7 @@ class Department extends SnipeModel */ public function company() { - return $this->belongsTo('\App\Models\Company', 'company_id'); + return $this->belongsTo(\App\Models\Company::class, 'company_id'); } /** @@ -83,7 +83,7 @@ class Department extends SnipeModel */ public function users() { - return $this->hasMany('\App\Models\User', 'department_id'); + return $this->hasMany(\App\Models\User::class, 'department_id'); } /** @@ -95,7 +95,7 @@ class Department extends SnipeModel */ public function manager() { - return $this->belongsTo('\App\Models\User', 'manager_id'); + return $this->belongsTo(\App\Models\User::class, 'manager_id'); } /** @@ -107,7 +107,7 @@ class Department extends SnipeModel */ public function location() { - return $this->belongsTo('\App\Models\Location', 'location_id'); + return $this->belongsTo(\App\Models\Location::class, 'location_id'); } /** diff --git a/app/Models/Depreciable.php b/app/Models/Depreciable.php index caced500c7..1492ea1965 100644 --- a/app/Models/Depreciable.php +++ b/app/Models/Depreciable.php @@ -25,7 +25,7 @@ class Depreciable extends SnipeModel public function depreciation() { - return $this->belongsTo('\App\Models\Depreciation', 'depreciation_id'); + return $this->belongsTo(\App\Models\Depreciation::class, 'depreciation_id'); } public function get_depreciation() diff --git a/app/Models/Depreciation.php b/app/Models/Depreciation.php index 2612f6ee1b..281524943a 100755 --- a/app/Models/Depreciation.php +++ b/app/Models/Depreciation.php @@ -8,7 +8,7 @@ use Watson\Validating\ValidatingTrait; class Depreciation extends SnipeModel { - protected $presenter = 'App\Presenters\DepreciationPresenter'; + protected $presenter = \App\Presenters\DepreciationPresenter::class; use Presentable; // Declare the rules for the form validation protected $rules = [ @@ -58,7 +58,7 @@ class Depreciation extends SnipeModel */ public function models() { - return $this->hasMany('\App\Models\AssetModel', 'depreciation_id'); + return $this->hasMany(\App\Models\AssetModel::class, 'depreciation_id'); } /** @@ -70,6 +70,6 @@ class Depreciation extends SnipeModel */ public function licenses() { - return $this->hasMany('\App\Models\License', 'depreciation_id'); + return $this->hasMany(\App\Models\License::class, 'depreciation_id'); } } diff --git a/app/Models/Group.php b/app/Models/Group.php index b493d02fef..ab432d2dd9 100755 --- a/app/Models/Group.php +++ b/app/Models/Group.php @@ -47,7 +47,7 @@ class Group extends SnipeModel */ public function users() { - return $this->belongsToMany('\App\Models\User', 'users_groups'); + return $this->belongsToMany(\App\Models\User::class, 'users_groups'); } /** diff --git a/app/Models/License.php b/app/Models/License.php index 027bb84d71..119e364509 100755 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -13,7 +13,7 @@ use Watson\Validating\ValidatingTrait; class License extends Depreciable { - protected $presenter = 'App\Presenters\LicensePresenter'; + protected $presenter = \App\Presenters\LicensePresenter::class; use SoftDeletes; use CompanyableTrait; @@ -264,7 +264,7 @@ class License extends Depreciable */ public function company() { - return $this->belongsTo('\App\Models\Company', 'company_id'); + return $this->belongsTo(\App\Models\Company::class, 'company_id'); } /** @@ -276,7 +276,7 @@ class License extends Depreciable */ public function category() { - return $this->belongsTo('\App\Models\Category', 'category_id'); + return $this->belongsTo(\App\Models\Category::class, 'category_id'); } /** @@ -288,7 +288,7 @@ class License extends Depreciable */ public function manufacturer() { - return $this->belongsTo('\App\Models\Manufacturer', 'manufacturer_id'); + return $this->belongsTo(\App\Models\Manufacturer::class, 'manufacturer_id'); } /** @@ -345,7 +345,7 @@ class License extends Depreciable */ public function assignedusers() { - return $this->belongsToMany('\App\Models\User', 'license_seats', 'assigned_to', 'license_id'); + return $this->belongsToMany(\App\Models\User::class, 'license_seats', 'assigned_to', 'license_id'); } /** @@ -357,7 +357,7 @@ class License extends Depreciable */ public function assetlog() { - return $this->hasMany('\App\Models\Actionlog', 'item_id') + return $this->hasMany(\App\Models\Actionlog::class, 'item_id') ->where('item_type', '=', self::class) ->orderBy('created_at', 'desc'); } @@ -371,7 +371,7 @@ class License extends Depreciable */ public function uploads() { - return $this->hasMany('\App\Models\Actionlog', 'item_id') + return $this->hasMany(\App\Models\Actionlog::class, 'item_id') ->where('item_type', '=', self::class) ->where('action_type', '=', 'uploaded') ->whereNotNull('filename') @@ -387,7 +387,7 @@ class License extends Depreciable */ public function adminuser() { - return $this->belongsTo('\App\Models\User', 'user_id'); + return $this->belongsTo(\App\Models\User::class, 'user_id'); } /** @@ -570,7 +570,7 @@ class License extends Depreciable */ public function licenseseats() { - return $this->hasMany('\App\Models\LicenseSeat'); + return $this->hasMany(\App\Models\LicenseSeat::class); } /** @@ -582,7 +582,7 @@ class License extends Depreciable */ public function supplier() { - return $this->belongsTo('\App\Models\Supplier', 'supplier_id'); + return $this->belongsTo(\App\Models\Supplier::class, 'supplier_id'); } /** @@ -614,7 +614,7 @@ class License extends Depreciable */ public function freeSeats() { - return $this->hasMany('\App\Models\LicenseSeat')->whereNull('assigned_to')->whereNull('deleted_at')->whereNull('asset_id'); + return $this->hasMany(\App\Models\LicenseSeat::class)->whereNull('assigned_to')->whereNull('deleted_at')->whereNull('asset_id'); } /** diff --git a/app/Models/LicenseSeat.php b/app/Models/LicenseSeat.php index e3a64332be..5d3a21f4b6 100755 --- a/app/Models/LicenseSeat.php +++ b/app/Models/LicenseSeat.php @@ -14,7 +14,7 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild use SoftDeletes; use Loggable; - protected $presenter = 'App\Presenters\LicenseSeatPresenter'; + protected $presenter = \App\Presenters\LicenseSeatPresenter::class; use Presentable; protected $dates = ['deleted_at']; @@ -64,7 +64,7 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild */ public function license() { - return $this->belongsTo('\App\Models\License', 'license_id'); + return $this->belongsTo(\App\Models\License::class, 'license_id'); } /** @@ -76,7 +76,7 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild */ public function user() { - return $this->belongsTo('\App\Models\User', 'assigned_to')->withTrashed(); + return $this->belongsTo(\App\Models\User::class, 'assigned_to')->withTrashed(); } /** @@ -88,7 +88,7 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild */ public function asset() { - return $this->belongsTo('\App\Models\Asset', 'asset_id')->withTrashed(); + return $this->belongsTo(\App\Models\Asset::class, 'asset_id')->withTrashed(); } /** diff --git a/app/Models/Location.php b/app/Models/Location.php index 9113f97d2f..4bb4c5f19a 100755 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -16,7 +16,7 @@ use Watson\Validating\ValidatingTrait; class Location extends SnipeModel { - protected $presenter = 'App\Presenters\LocationPresenter'; + protected $presenter = \App\Presenters\LocationPresenter::class; use Presentable; use SoftDeletes; protected $dates = ['deleted_at']; @@ -97,12 +97,12 @@ class Location extends SnipeModel public function users() { - return $this->hasMany('\App\Models\User', 'location_id'); + return $this->hasMany(\App\Models\User::class, 'location_id'); } public function assets() { - return $this->hasMany('\App\Models\Asset', 'location_id') + return $this->hasMany(\App\Models\Asset::class, 'location_id') ->whereHas('assetstatus', function ($query) { $query->where('status_labels.deployable', '=', 1) ->orWhere('status_labels.pending', '=', 1) @@ -123,30 +123,30 @@ class Location extends SnipeModel In all likelyhood, we need to denorm an "effective_location" column into Assets to make this slightly less miserable. */ - return $this->hasMany('\App\Models\Asset', 'rtd_location_id'); + return $this->hasMany(\App\Models\Asset::class, 'rtd_location_id'); } public function parent() { - return $this->belongsTo('\App\Models\Location', 'parent_id', 'id') + return $this->belongsTo(\App\Models\Location::class, 'parent_id', 'id') ->with('parent'); } public function manager() { - return $this->belongsTo('\App\Models\User', 'manager_id'); + return $this->belongsTo(\App\Models\User::class, 'manager_id'); } public function children() { - return $this->hasMany('\App\Models\Location', 'parent_id') + return $this->hasMany(\App\Models\Location::class, 'parent_id') ->with('children'); } // I don't think we need this anymore since we de-normed location_id in assets? public function assignedAssets() { - return $this->morphMany('App\Models\Asset', 'assigned', 'assigned_type', 'assigned_to')->withTrashed(); + return $this->morphMany(\App\Models\Asset::class, 'assigned', 'assigned_type', 'assigned_to')->withTrashed(); } public function setLdapOuAttribute($ldap_ou) diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php index c5bd3e18d9..5d12b1d786 100755 --- a/app/Models/Manufacturer.php +++ b/app/Models/Manufacturer.php @@ -10,7 +10,7 @@ use Watson\Validating\ValidatingTrait; class Manufacturer extends SnipeModel { - protected $presenter = 'App\Presenters\ManufacturerPresenter'; + protected $presenter = \App\Presenters\ManufacturerPresenter::class; use Presentable; use SoftDeletes; protected $dates = ['deleted_at']; @@ -77,26 +77,26 @@ class Manufacturer extends SnipeModel public function assets() { - return $this->hasManyThrough('\App\Models\Asset', '\App\Models\AssetModel', 'manufacturer_id', 'model_id'); + return $this->hasManyThrough(\App\Models\Asset::class, \App\Models\AssetModel::class, 'manufacturer_id', 'model_id'); } public function models() { - return $this->hasMany('\App\Models\AssetModel', 'manufacturer_id'); + return $this->hasMany(\App\Models\AssetModel::class, 'manufacturer_id'); } public function licenses() { - return $this->hasMany('\App\Models\License', 'manufacturer_id'); + return $this->hasMany(\App\Models\License::class, 'manufacturer_id'); } public function accessories() { - return $this->hasMany('\App\Models\Accessory', 'manufacturer_id'); + return $this->hasMany(\App\Models\Accessory::class, 'manufacturer_id'); } public function consumables() { - return $this->hasMany('\App\Models\Consumable', 'manufacturer_id'); + return $this->hasMany(\App\Models\Consumable::class, 'manufacturer_id'); } } diff --git a/app/Models/PredefinedKit.php b/app/Models/PredefinedKit.php index 9bc8f86c1f..1bf6cb098b 100644 --- a/app/Models/PredefinedKit.php +++ b/app/Models/PredefinedKit.php @@ -15,7 +15,7 @@ use Watson\Validating\ValidatingTrait; */ class PredefinedKit extends SnipeModel { - protected $presenter = 'App\Presenters\PredefinedKitPresenter'; + protected $presenter = \App\Presenters\PredefinedKitPresenter::class; use Presentable; protected $table = 'kits'; @@ -139,12 +139,12 @@ class PredefinedKit extends SnipeModel */ public function models() { - return $this->belongsToMany('\App\Models\AssetModel', 'kits_models', 'kit_id', 'model_id')->withPivot('id', 'quantity'); + return $this->belongsToMany(\App\Models\AssetModel::class, 'kits_models', 'kit_id', 'model_id')->withPivot('id', 'quantity'); } public function assets() { - return $this->hasManyThrough('\App\Models\Asset', '\App\Models\AssetModel', 'country_id', 'user_id'); + return $this->hasManyThrough(\App\Models\Asset::class, \App\Models\AssetModel::class, 'country_id', 'user_id'); } /** @@ -153,7 +153,7 @@ class PredefinedKit extends SnipeModel */ public function licenses() { - return $this->belongsToMany('\App\Models\License', 'kits_licenses', 'kit_id', 'license_id')->withPivot('id', 'quantity'); + return $this->belongsToMany(\App\Models\License::class, 'kits_licenses', 'kit_id', 'license_id')->withPivot('id', 'quantity'); } /** @@ -162,7 +162,7 @@ class PredefinedKit extends SnipeModel */ public function consumables() { - return $this->belongsToMany('\App\Models\Consumable', 'kits_consumables', 'kit_id', 'consumable_id')->withPivot('id', 'quantity'); + return $this->belongsToMany(\App\Models\Consumable::class, 'kits_consumables', 'kit_id', 'consumable_id')->withPivot('id', 'quantity'); } /** @@ -171,7 +171,7 @@ class PredefinedKit extends SnipeModel */ public function accessories() { - return $this->belongsToMany('\App\Models\Accessory', 'kits_accessories', 'kit_id', 'accessory_id')->withPivot('id', 'quantity'); + return $this->belongsToMany(\App\Models\Accessory::class, 'kits_accessories', 'kit_id', 'accessory_id')->withPivot('id', 'quantity'); } /** diff --git a/app/Models/Statuslabel.php b/app/Models/Statuslabel.php index 681dd08307..17a277db7b 100755 --- a/app/Models/Statuslabel.php +++ b/app/Models/Statuslabel.php @@ -59,7 +59,7 @@ class Statuslabel extends SnipeModel */ public function assets() { - return $this->hasMany('\App\Models\Asset', 'status_id'); + return $this->hasMany(\App\Models\Asset::class, 'status_id'); } /** diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php index 285147b079..0b38c01683 100755 --- a/app/Models/Supplier.php +++ b/app/Models/Supplier.php @@ -104,7 +104,7 @@ class Supplier extends SnipeModel */ public function assets() { - return $this->hasMany('\App\Models\Asset', 'supplier_id'); + return $this->hasMany(\App\Models\Asset::class, 'supplier_id'); } /** @@ -116,7 +116,7 @@ class Supplier extends SnipeModel */ public function accessories() { - return $this->hasMany('\App\Models\Accessory', 'supplier_id'); + return $this->hasMany(\App\Models\Accessory::class, 'supplier_id'); } /** @@ -128,7 +128,7 @@ class Supplier extends SnipeModel */ public function asset_maintenances() { - return $this->hasMany('\App\Models\AssetMaintenance', 'supplier_id'); + return $this->hasMany(\App\Models\AssetMaintenance::class, 'supplier_id'); } /** @@ -156,7 +156,7 @@ class Supplier extends SnipeModel */ public function licenses() { - return $this->hasMany('\App\Models\License', 'supplier_id'); + return $this->hasMany(\App\Models\License::class, 'supplier_id'); } /** diff --git a/app/Models/User.php b/app/Models/User.php index 4a0fbfc934..f9d4a4071f 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -21,7 +21,7 @@ use Watson\Validating\ValidatingTrait; class User extends SnipeModel implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract, HasLocalePreference { - protected $presenter = 'App\Presenters\UserPresenter'; + protected $presenter = \App\Presenters\UserPresenter::class; use SoftDeletes, ValidatingTrait; use Authenticatable, Authorizable, CanResetPassword, HasApiTokens; use UniqueUndeletedTrait; @@ -188,7 +188,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function company() { - return $this->belongsTo('\App\Models\Company', 'company_id'); + return $this->belongsTo(\App\Models\Company::class, 'company_id'); } /** @@ -200,7 +200,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function department() { - return $this->belongsTo('\App\Models\Department', 'department_id'); + return $this->belongsTo(\App\Models\Department::class, 'department_id'); } /** @@ -264,7 +264,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function assets() { - return $this->morphMany('App\Models\Asset', 'assigned', 'assigned_type', 'assigned_to')->withTrashed(); + return $this->morphMany(\App\Models\Asset::class, 'assigned', 'assigned_type', 'assigned_to')->withTrashed(); } /** @@ -279,7 +279,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function assetmaintenances() { - return $this->hasMany('\App\Models\AssetMaintenance', 'user_id')->withTrashed(); + return $this->hasMany(\App\Models\AssetMaintenance::class, 'user_id')->withTrashed(); } /** @@ -291,7 +291,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function accessories() { - return $this->belongsToMany('\App\Models\Accessory', 'accessories_users', 'assigned_to', 'accessory_id') + return $this->belongsToMany(\App\Models\Accessory::class, 'accessories_users', 'assigned_to', 'accessory_id') ->withPivot('id', 'created_at', 'note')->withTrashed(); } @@ -304,7 +304,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function consumables() { - return $this->belongsToMany('\App\Models\Consumable', 'consumables_users', 'assigned_to', 'consumable_id')->withPivot('id')->withTrashed(); + return $this->belongsToMany(\App\Models\Consumable::class, 'consumables_users', 'assigned_to', 'consumable_id')->withPivot('id')->withTrashed(); } /** @@ -316,7 +316,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function licenses() { - return $this->belongsToMany('\App\Models\License', 'license_seats', 'assigned_to', 'license_id')->withPivot('id'); + return $this->belongsToMany(\App\Models\License::class, 'license_seats', 'assigned_to', 'license_id')->withPivot('id'); } /** @@ -328,7 +328,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function userlog() { - return $this->hasMany('\App\Models\Actionlog', 'target_id')->where('target_type', '=', 'App\Models\User')->orderBy('created_at', 'DESC')->withTrashed(); + return $this->hasMany(\App\Models\Actionlog::class, 'target_id')->where('target_type', '=', \App\Models\User::class)->orderBy('created_at', 'DESC')->withTrashed(); } /** @@ -344,7 +344,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function userloc() { - return $this->belongsTo('\App\Models\Location', 'location_id')->withTrashed(); + return $this->belongsTo(\App\Models\Location::class, 'location_id')->withTrashed(); } /** @@ -356,7 +356,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function location() { - return $this->belongsTo('\App\Models\Location', 'location_id')->withTrashed(); + return $this->belongsTo(\App\Models\Location::class, 'location_id')->withTrashed(); } /** @@ -368,7 +368,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function manager() { - return $this->belongsTo('\App\Models\User', 'manager_id')->withTrashed(); + return $this->belongsTo(\App\Models\User::class, 'manager_id')->withTrashed(); } /** @@ -380,7 +380,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function managedLocations() { - return $this->hasMany('\App\Models\Location', 'manager_id'); + return $this->hasMany(\App\Models\Location::class, 'manager_id'); } /** @@ -392,7 +392,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function groups() { - return $this->belongsToMany('\App\Models\Group', 'users_groups'); + return $this->belongsToMany(\App\Models\Group::class, 'users_groups'); } /** @@ -404,7 +404,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function assetlog() { - return $this->hasMany('\App\Models\Asset', 'id')->withTrashed(); + return $this->hasMany(\App\Models\Asset::class, 'id')->withTrashed(); } /** @@ -418,7 +418,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo */ public function uploads() { - return $this->hasMany('\App\Models\Actionlog', 'item_id') + return $this->hasMany(\App\Models\Actionlog::class, 'item_id') ->where('item_type', self::class) ->where('action_type', '=', 'uploaded') ->whereNotNull('filename') diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 6a454d28eb..1f08b445c9 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -15,11 +15,11 @@ class EventServiceProvider extends ServiceProvider */ protected $listen = [ 'Illuminate\Auth\Events\Login' => [ - 'App\Listeners\LogSuccessfulLogin', + \App\Listeners\LogSuccessfulLogin::class, ], 'Illuminate\Auth\Events\Failed' => [ - 'App\Listeners\LogFailedLogin', + \App\Listeners\LogFailedLogin::class, ], ]; diff --git a/database/migrations/2016_09_04_182149_migrate_asset_log_to_action_log.php b/database/migrations/2016_09_04_182149_migrate_asset_log_to_action_log.php index b27c602741..874f7a6070 100644 --- a/database/migrations/2016_09_04_182149_migrate_asset_log_to_action_log.php +++ b/database/migrations/2016_09_04_182149_migrate_asset_log_to_action_log.php @@ -26,20 +26,20 @@ class MigrateAssetLogToActionLog extends Migration if (! is_null($log->asset_id)) { $a->item_id = $log->asset_id; if ($log->asset_type == 'hardware') { - $a->item_type = 'App\\Models\\Asset'; + $a->item_type = \App\Models\Asset::class; } else { - $a->item_type = 'App\\Models\\License'; + $a->item_type = \App\Models\License::class; } } if (! is_null($log->accessory_id)) { $a->item_id = $log->accessory_id; - $a->item_type = 'App\\Models\\Accessory'; + $a->item_type = \App\Models\Accessory::class; } elseif (! is_null($log->consumable_id)) { $a->item_id = $log->consumable_id; - $a->item_type = 'App\\Models\\Consumable'; + $a->item_type = \App\Models\Consumable::class; } elseif (! is_null($log->component_id)) { $a->item_id = $log->component_id; - $a->item_type = 'App\\Models\\Component'; + $a->item_type = \App\Models\Component::class; } $a->action_type = $log->action_type; // $a->checkout_to = $log->checkout_to; diff --git a/database/migrations/2016_11_24_160405_add_missing_target_type_to_logs_table.php b/database/migrations/2016_11_24_160405_add_missing_target_type_to_logs_table.php index 14bbea529f..bf0b5360a1 100644 --- a/database/migrations/2016_11_24_160405_add_missing_target_type_to_logs_table.php +++ b/database/migrations/2016_11_24_160405_add_missing_target_type_to_logs_table.php @@ -17,7 +17,7 @@ class AddMissingTargetTypeToLogsTable extends Migration DB::table('action_logs')->where('target_type', null)->where(function ($query) { $query->where('action_type', 'accepted') ->orWhere('action_type', 'declined'); - })->update(['target_type'=> 'App\Models\User']); + })->update(['target_type'=> \App\Models\User::class]); } /** diff --git a/database/migrations/2017_09_18_225619_fix_assigned_type_not_being_nulled.php b/database/migrations/2017_09_18_225619_fix_assigned_type_not_being_nulled.php index b9d2239981..ef7c3cd4c0 100644 --- a/database/migrations/2017_09_18_225619_fix_assigned_type_not_being_nulled.php +++ b/database/migrations/2017_09_18_225619_fix_assigned_type_not_being_nulled.php @@ -21,7 +21,7 @@ class FixAssignedTypeNotBeingNulled extends Migration // Additionally, the importer did not set assigned_type when importing. // In the case where we have an assigned_to but not an assigned_type, set the assigned_type to User. - Asset::whereNotNull('assigned_to')->whereNull('assigned_type')->update(['assigned_type' => 'App\Models\User']); + Asset::whereNotNull('assigned_to')->whereNull('assigned_type')->update(['assigned_type' => \App\Models\User::class]); } /** diff --git a/database/migrations/2018_09_10_082212_create_checkout_acceptances_for_unaccepted_assets.php b/database/migrations/2018_09_10_082212_create_checkout_acceptances_for_unaccepted_assets.php index 3783a568ed..2885f5ef84 100644 --- a/database/migrations/2018_09_10_082212_create_checkout_acceptances_for_unaccepted_assets.php +++ b/database/migrations/2018_09_10_082212_create_checkout_acceptances_for_unaccepted_assets.php @@ -16,13 +16,13 @@ class CreateCheckoutAcceptancesForUnacceptedAssets extends Migration public function up() { // Get all assets not accepted - $assets = DB::table('assets')->where('assigned_type', 'App\Models\User')->where('accepted', 'pending')->get(); + $assets = DB::table('assets')->where('assigned_type', \App\Models\User::class)->where('accepted', 'pending')->get(); $acceptances = []; foreach ($assets as $asset) { $acceptances[] = [ - 'checkoutable_type' => 'App\Models\Asset', + 'checkoutable_type' => \App\Models\Asset::class, 'checkoutable_id' => $asset->id, 'assigned_to_id' => $asset->assigned_to, ]; diff --git a/database/migrations/2020_10_22_233743_move_accessory_checkout_note_to_join_table.php b/database/migrations/2020_10_22_233743_move_accessory_checkout_note_to_join_table.php index cbf1e2d070..feea0d95a1 100644 --- a/database/migrations/2020_10_22_233743_move_accessory_checkout_note_to_join_table.php +++ b/database/migrations/2020_10_22_233743_move_accessory_checkout_note_to_join_table.php @@ -43,7 +43,7 @@ class MoveAccessoryCheckoutNoteToJoinTable extends Migration $action_log_entries = Actionlog::where('created_at', '=', $join_log->created_at) ->where('target_id', '=', $join_log->assigned_to) ->where('item_id', '=', $accessory->id) - ->where('target_type', '=', 'App\\Models\\User') + ->where('target_type', '=', \App\Models\User::class) ->where('action_type', '=', 'checkout') ->orderBy('created_at', 'DESC')->get(); diff --git a/tests/api/ApiCheckoutAssetsCest.php b/tests/api/ApiCheckoutAssetsCest.php index 77c77615f6..4e137785d2 100644 --- a/tests/api/ApiCheckoutAssetsCest.php +++ b/tests/api/ApiCheckoutAssetsCest.php @@ -25,7 +25,7 @@ class ApiCheckoutAssetsCest $I->wantTo('Check out an asset to a user'); //Grab an asset from the database that isn't checked out. $asset = Asset::whereNull('assigned_to')->first(); - $targetUser = factory('App\Models\User')->create(); + $targetUser = factory(\App\Models\User::class)->create(); $data = [ 'assigned_user' => $targetUser->id, 'note' => 'This is a test checkout note', @@ -62,7 +62,7 @@ class ApiCheckoutAssetsCest ->where('model_id', 8) ->where('status_id', Statuslabel::deployable()->first()->id) ->first(); // We need to make sure that this is an asset/model that doesn't require acceptance - $targetAsset = factory('App\Models\Asset')->states('desktop-macpro')->create([ + $targetAsset = factory(\App\Models\Asset::class)->states('desktop-macpro')->create([ 'name' => 'Test Asset For Checkout to', ]); $data = [ @@ -96,7 +96,7 @@ class ApiCheckoutAssetsCest ->where('model_id', 8) ->where('status_id', Statuslabel::deployable()->first()->id) ->first(); // We need to make sure that this is an asset/model that doesn't require acceptance - $targetLocation = factory('App\Models\Location')->create([ + $targetLocation = factory(\App\Models\Location::class)->create([ 'name' => 'Test Location for Checkout', ]); $data = [ diff --git a/tests/functional/AssetsCest.php b/tests/functional/AssetsCest.php index 4f35534baa..e08b26069c 100644 --- a/tests/functional/AssetsCest.php +++ b/tests/functional/AssetsCest.php @@ -62,7 +62,7 @@ class AssetsCest $seenValues = [ 'asset_tag' => $asset->asset_tag, 'assigned_to' => $userId, - 'assigned_type' => 'App\\Models\\User', + 'assigned_type' => \App\Models\User::class, 'company_id' => $asset->company_id, 'model_id' => $asset->model_id, 'name' => $asset->name,