Backend Boilerplates
php
Advanced
Laravel Repository Pattern
Repository + Interface pattern for Laravel Eloquent decoupling and testability.
php
interface ModuleRepositoryInterface {
public function paginate(int $perPage): LengthAwarePaginator;
public function findBySlug(string $slug): ?Module;
}
class EloquentModuleRepository implements ModuleRepositoryInterface {
public function paginate(int $perPage): LengthAwarePaginator {
return Module::where('is_published', true)->latest('published_at')->paginate($perPage);
}
public function findBySlug(string $slug): ?Module {
return Module::where('slug', $slug)->firstOrFail();
}
}
Prerequisites
- Laravel >= 10
Pro Tips
- → Bind the interface in AppServiceProvider.
Commercial Licensing
Acquire a production access token or template license for enterprise deployment.
Module Info
- Language
- php
- Level
- Advanced
- Read time
- 5 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