@@ 554-562 (lines=9) @@ | ||
551 | * |
|
552 | * @return \Illuminate\Database\Eloquent\Builder|static |
|
553 | */ |
|
554 | public function scopeWhereTranslation(Builder $query, $key, $value, $locale = null) |
|
555 | { |
|
556 | return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
|
557 | $query->where($this->getTranslationsTable().'.'.$key, $value); |
|
558 | if ($locale) { |
|
559 | $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale); |
|
560 | } |
|
561 | }); |
|
562 | } |
|
563 | ||
564 | /** |
|
565 | * This scope filters results by checking the translation fields. |
|
@@ 574-582 (lines=9) @@ | ||
571 | * |
|
572 | * @return \Illuminate\Database\Eloquent\Builder|static |
|
573 | */ |
|
574 | public function scopeWhereTranslationLike(Builder $query, $key, $value, $locale = null) |
|
575 | { |
|
576 | return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
|
577 | $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value); |
|
578 | if ($locale) { |
|
579 | $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale); |
|
580 | } |
|
581 | }); |
|
582 | } |
|
583 | ||
584 | /** |
|
585 | * @return array |