From e1b33f308787efbcc43509d9d591a4bc2c772cd2 Mon Sep 17 00:00:00 2001 From: Thomas Misilo Date: Thu, 27 Jun 2019 20:33:13 -0500 Subject: [PATCH 1/2] Spelling Correction (#7206) Fixed Spelling for the word reqrite, to be rewrite. --- app/Console/Commands/Purge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/Purge.php b/app/Console/Commands/Purge.php index d5f7cab503..6ba1712f84 100644 --- a/app/Console/Commands/Purge.php +++ b/app/Console/Commands/Purge.php @@ -33,7 +33,7 @@ class Purge extends Command * * @var string */ - protected $description = 'Purge all soft-deleted deleted records in the database. This will rewrite history for items that have been edited, or checked in or out. It will also reqrite history for users associated with deleted items.'; + protected $description = 'Purge all soft-deleted deleted records in the database. This will rewrite history for items that have been edited, or checked in or out. It will also rewrite history for users associated with deleted items.'; /** * Create a new command instance. From d409be6d43579b840ac3056b755cf7643c35edc6 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Date: Mon, 15 Jul 2019 15:02:44 -0500 Subject: [PATCH 2/2] Fix #6910: Add logic to manipulate the eloquent query. (#7006) * Added company_id to consumables_users table * Added logic to manage when a pivot table doesn't have the column company_id trough a join with users * Remove a migration that tries to fix this problem, but is not longer necessary --- app/Http/Controllers/Api/ConsumablesController.php | 2 +- app/Models/Company.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/ConsumablesController.php b/app/Http/Controllers/Api/ConsumablesController.php index 8a258dbea1..661eab4c5d 100644 --- a/app/Http/Controllers/Api/ConsumablesController.php +++ b/app/Http/Controllers/Api/ConsumablesController.php @@ -165,7 +165,7 @@ class ConsumablesController extends Controller { $consumable = Consumable::with(array('consumableAssignments'=> function ($query) { - $query->orderBy('created_at', 'DESC'); + $query->orderBy($query->getModel()->getTable().'.created_at', 'DESC'); }, 'consumableAssignments.admin'=> function ($query) { }, diff --git a/app/Models/Company.php b/app/Models/Company.php index 391a79d6b2..bb3467c38c 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -80,7 +80,13 @@ final class Company extends SnipeModel } $table = ($table_name) ? DB::getTablePrefix().$table_name."." : ''; - return $query->where($table.$column, '=', $company_id); + + if(\Schema::hasColumn($query->getModel()->getTable(), $column)){ + return $query->where($table.$column, '=', $company_id); + } else { + return $query->join('users as users_comp', 'users_comp.id', 'user_id')->where('users_comp.company_id', '=', $company_id); + } + } public static function getIdFromInput($unescaped_input)