Skip to content

Commit

Permalink
Add locale scope to Asset
Browse files Browse the repository at this point in the history
  • Loading branch information
bbs-smuller committed Jul 2, 2018
1 parent a8e8bad commit e3c0584
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Distilleries/Contentful/Models/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,18 @@ class Asset extends Model
'width' => 'integer',
'height' => 'integer',
];

/**
* Scope a query to a given locale.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $locale
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeLocale($query, string $locale = '') : Builder
{
$locale = ! empty($locale) ? $locale : Locale::default();

return $query->where($this->getTable() . '.locale', '=', $locale);
}
}

0 comments on commit e3c0584

Please sign in to comment.