From d1304cc975aee94515cf60c6c3020cc0d2c51dc8 Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Mon, 30 Aug 2021 13:44:26 -0500 Subject: [PATCH] Add sentence to infer the table's name according to the query passed --- app/Models/Company.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Models/Company.php b/app/Models/Company.php index 04f138ccd0..99f6e3851d 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -78,12 +78,12 @@ final class Company extends SnipeModel $company_id = null; } - $table = ($table_name) ? $table_name."." : ''; + $table = ($table_name) ? $table_name."." : $query->getModel()->getTable()."."; if(\Schema::hasColumn($query->getModel()->getTable(), $column)){ - return $query->where($table.$column, '=', $company_id); + 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); + return $query->join('users as users_comp', 'users_comp.id', 'user_id')->where('users_comp.company_id', '=', $company_id); } }