Backend Boilerplates
php
Beginner
Laravel Eloquent Published Scope
Reusable Eloquent local scope to filter only published records.
php
// In your model
public function scopePublished(Builder $query): Builder {
return $query->where('is_published', true)
->whereNotNull('published_at')
->where('published_at', '<=', now());
}
// Usage
$modules = Module::published()->latest('published_at')->paginate(12);
Prerequisites
- Laravel >= 10
Pro Tips
- → Chain with other scopes freely.
Commercial Licensing
Acquire a production access token or template license for enterprise deployment.
Module Info
- Language
- php
- Level
- Beginner
- Read time
- 2 min
- Published
- Aug 2024
- License
- Commercial License
Newsletter
New modules every week, directly to your inbox.
Similar Modules
Laravel Artisan Seeder Command
Artisan command to re-seed production data with a confirmation prompt.
php
·
Intermediate
CSV to PostgreSQL Bulk Loader
Stream a large CSV directly into PostgreSQL using COPY for maximum throughput.
python
·
Intermediate
Go Event Sourcing Store
Minimal append-only event store in Go backed by a Postgres table.
go
·
Advanced