Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

driesvints/driesvints.com

74 stars
2 code files
View driesvints/driesvints.com on GitHub

app/Models/Post.php

Open in GitHub
use Illuminate\Database\Eloquent\Model;
 
final class Post extends Model
{
public function scopePublished(Builder $query): Builder
{
return $query->where('published_at', '<=', now());
}
}

app/Http/Controllers/BlogController.php

Open in GitHub
use App\Models\Post;
 
final class BlogController
{
public function __invoke()
{
$posts = Post::published()->orderByDesc('published_at')->get();
 
return view('blog', compact('posts'));
}
}

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.