Skip to content

Tips

Some tips with Laravel

Shorcut Where relationships

php
// Before:

User::whereHas('posts', function ($query) {
  $query->where('published_at', '>', now());
})->get();

// After
User::whereRelation('posts', 'published_at', '>', now());

MIT License