public function searchByTerm($table, $searchTerm, $limit, $searchInAllColumns = true, $columns = array(), $excludeColumns = array(), $orderBy = 'created_at', $orderType = 'DESC', $joins = array(), $conditions = array())
    {
        $langSlug = App::getLocale();

        if($searchInAllColumns && !$columns) {
            $columns = DB::connection($this->DATABASE_CONNECTION)->select(DB::connection($this->DATABASE_CONNECTION)->raw("SHOW COLUMNS FROM $table FROM ".DB::getDatabaseName()));
            if(!$columns) {
                throw new \Exception("No columns could be found for table:".$table);
            }
        }
        // get table
        $queryObject = DB::connection($this->DATABASE_CONNECTION)->table($table);

        // use where clause for each column
        foreach ($columns as $column){
            if ($column->Field != 'password') {
                if(!in_array($column->Field, $excludeColumns)) {
                    if ($searchInAllColumns) {
                        if ($column->Type == "json") {
                            $queryObject->orWhere($column->Field.'->'.$langSlug, 'like', '%'.$searchTerm.'%');
                        }else{
                            $queryObject->orWhere($column->Field, 'like', '%'.$searchTerm.'%');
                        }
                    }else{
                        $queryObject->orWhere($column->Field, 'like', '%'.$searchTerm.'%');
                    }
                }

                if($conditions) {
                    foreach ($conditions as $condition){
                        $method = $condition[0];
                        $queryObject->$method($condition[1], $condition[2], $condition[3]);
                    }
                }
            }
        }

        if($joins != '') {
            foreach ($joins as $join){
                if($join['type'] == 'left') { // if it is a left join
                    $queryObject->leftJoin($join['table'], $table.'.'.$join['whereTable1'], '=', $join['table'].'.'.$join['whereTable2']);
                }else if($join['type'] == 'inner') { // if it is a inner join
                    $queryObject->join($join['table'], $table.'.'.$join['whereTable1'], '=', $join['table'].'.'.$join['whereTable2']);
                }
            }
        }

        return $queryObject->orderBy($orderBy, $orderType)
            ->paginate($limit);
    }