17 use Illuminate\Database\Capsule\Manager as Capsule;
86 ->select(
'c.' . $this->dbIdColumn)
97 ->select(
'c.' . $this->dbIdColumn)
98 ->pluck(
'c.' . $this->dbIdColumn)
114 'c.' . $this->dbIdColumn .
' as id',
116 'cst.setting_value as name',
120 ->leftJoin($this->dbSettings .
' as cst',
function($q) {
121 $q->where(
'cst.' . $this->dbIdColumn,
'=', Capsule::raw(
'c.' . $this->dbIdColumn))
122 ->where(
'cst.setting_name',
'=',
'name')
123 ->where(
'cst.locale',
'=', Capsule::raw(
'c.primary_locale'));
126 'c.' . $this->dbIdColumn,
137 $this->columns[] =
'c.*';
138 $q = Capsule::table($this->db .
' as c')
139 ->leftJoin($this->dbSettings .
' as cs',
'cs.' . $this->dbIdColumn,
'=',
'c.' . $this->dbIdColumn)
140 ->groupBy(
'c.' . $this->dbIdColumn);
142 if (!empty($this->isEnabled)) {
143 $q->where(
'c.enabled',
'=', 1);
144 } elseif ($this->isEnabled ===
false) {
145 $q->where(
'c.enabled',
'!=', 1);
148 if (!empty($this->userId)) {
149 $q->leftJoin(
'user_groups as ug',
'ug.context_id',
'=',
'c.' . $this->dbIdColumn)
150 ->leftJoin(
'user_user_groups as uug',
'uug.user_group_id',
'=',
'ug.user_group_id')
151 ->where(
function($q) {
152 $q->where(
'uug.user_id',
'=', $this->userId)
153 ->where(
function($q) {
154 $q->where(
'ug.role_id',
'=', ROLE_ID_MANAGER)
155 ->orWhere(
'c.enabled',
'=', 1);
164 foreach ($words as $word) {
165 $q->where(
function($q) use ($word) {
166 $q->where(
function($q) use ($word) {
167 $q->where(
'cs.setting_name',
'name');
168 $q->where(
'cs.setting_value',
'LIKE',
"%{$word}%");
170 ->orWhere(
function($q) use ($word) {
171 $q->where(
'cs.setting_name',
'description');
172 $q->where(
'cs.setting_value',
'LIKE',
"%{$word}%");
174 ->orWhere(
function($q) use ($word) {
175 $q->where(
'cs.setting_name',
'acronym');
176 $q->where(
'cs.setting_value',
'LIKE',
"%{$word}%");
178 ->orWhere(
function($q) use ($word) {
179 $q->where(
'cs.setting_name',
'abbreviation');
180 $q->where(
'cs.setting_value',
'LIKE',
"%{$word}%");
190 $q->select($this->columns);