Add sentence to infer the table's name according to the query passed

This commit is contained in:
Ivan Nieto Vivanco 2021-08-30 13:44:26 -05:00
parent 085be16966
commit d1304cc975

View file

@ -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);
}
}