Skip to main content

laravelio/laravel.io

2499 stars
1 code files
View laravelio/laravel.io on GitHub

app/Models/Article.php

Open in GitHub
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
 
final class Article extends Model
{
//
public function scopeForTag(Builder $query, string $tag): Builder
{
return $query->whereHas('tagsRelation', function ($query) use ($tag) {
$query->where('tags.slug', $tag);
});
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.