From d1fe7abb18d54d8e9f4b7cabbe3acf904824480e Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 24 Jan 2019 14:47:44 -0800 Subject: [PATCH] Replaced custom deleted query scopes with onlyTrashed() --- app/Http/Controllers/Api/AssetsController.php | 2 +- app/Http/Controllers/Api/UsersController.php | 2 +- app/Models/Asset.php | 13 ---------- app/Models/AssetModel.php | 11 --------- app/Models/User.php | 24 ------------------- 5 files changed, 2 insertions(+), 50 deletions(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index d451b38116..53fc59ea8d 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -156,7 +156,7 @@ class AssetsController extends Controller // I am sad. :( switch ($request->input('status')) { case 'Deleted': - $assets->withTrashed()->Deleted(); + $assets->onlyTrashed(); break; case 'Pending': $assets->join('status_labels AS status_alias',function ($join) { diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index f9ec409839..2535fac249 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -63,7 +63,7 @@ class UsersController extends Controller if (($request->filled('deleted')) && ($request->input('deleted')=='true')) { - $users = $users->GetDeleted(); + $users = $users->onlyTrashed(); } if ($request->filled('company_id')) { diff --git a/app/Models/Asset.php b/app/Models/Asset.php index 0a5434cb91..8909636059 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -1052,19 +1052,6 @@ class Asset extends Depreciable } - /** - * Query builder scope for Deleted assets - * - * @param \Illuminate\Database\Query\Builder $query Query builder instance - * - * @return \Illuminate\Database\Query\Builder Modified query builder - */ - - public function scopeDeleted($query) - { - return $query->whereNotNull('assets.deleted_at'); - } - /** * scopeInModelList * Get all assets in the provided listing of model ids diff --git a/app/Models/AssetModel.php b/app/Models/AssetModel.php index 1998b277de..e2d58fa40d 100755 --- a/app/Models/AssetModel.php +++ b/app/Models/AssetModel.php @@ -187,17 +187,6 @@ class AssetModel extends SnipeModel * ----------------------------------------------- **/ - /** - * Query builder scope for Deleted assets - * - * @param \Illuminate\Database\Query\Builder $query Query builder instance - * @return \Illuminate\Database\Query\Builder Modified query builder - */ - - public function scopeDeleted($query) - { - return $query->whereNotNull('deleted_at'); - } /** * scopeInCategory diff --git a/app/Models/User.php b/app/Models/User.php index d5d93839da..d291fdbf4a 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -440,18 +440,6 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo return $this->belongsToMany(Asset::class, 'checkout_requests', 'user_id', 'requestable_id')->whereNull('canceled_at'); } - /** - * Query builder scope to return deleted users - * @author A. Gianotto - * @since [v2.0] - * - * @param string $query - * @return \Illuminate\Database\Query\Builder - */ - public function scopeGetDeleted($query) - { - return $query->withTrashed()->whereNotNull('users.deleted_at'); - } /** * Query builder scope to return NOT-deleted users @@ -591,18 +579,6 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo }); } - /** - * Query builder scope for Deleted users - * - * @param \Illuminate\Database\Query\Builder $query Query builder instance - * @return \Illuminate\Database\Query\Builder Modified query builder - */ - - public function scopeDeleted($query) - { - return $query->whereNotNull('deleted_at'); - } - /** * Query builder scope to order on manager