prism-x /
laravel-schemaless
| 1 | <?php |
||
| 2 | |||
| 3 | namespace PrismX\Schemaless\Traits; |
||
| 4 | |||
| 5 | trait HasFetchScope |
||
| 6 | { |
||
| 7 | public function scopeFetch($query, $locale = null) |
||
| 8 | { |
||
| 9 | return $query |
||
| 10 | ->where('collection', $this->collection) |
||
| 11 | ->where('locale', $locale ?? app()->getLocale()) |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 12 | ->firstOrFail(); |
||
| 13 | } |
||
| 14 | |||
| 15 | public function scopeFetchAll($query, $locale = null) |
||
| 16 | { |
||
| 17 | return $query |
||
| 18 | ->where('collection', $this->collection) |
||
| 19 | ->where('locale', $locale ?? app()->getLocale()) |
||
| 20 | ->get(); |
||
| 21 | } |
||
| 22 | } |
||
| 23 |