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