laravel-base-repository maintained by viniciusjpsilva
Description
A reusable base repository implementation for Laravel.
Author
Last update
2026/07/18 15:46
(dev-main)
License
Downloads
0
Tags
Laravel Base Repository
A lightweight base repository implementation for Laravel applications, providing a reusable and consistent API for common Eloquent operations.
Installation
composer require viniciusjpsilva/laravel-base-repository
Usage
Create your repository by extending BaseRepository.
<?php
namespace App\Repositories;
use App\Models\User;
use ViniciusJPSilva\Repositories\BaseRepository;
class UserRepository extends BaseRepository
{
public function __construct()
{
parent::__construct(new User());
}
}
Use the repository as you would any other service.
$user = $repository->find(1);
$users = $repository->get(
callback: fn ($query) => $query
->where('active', true)
->orderBy('name')
);
$repository->create([
'name' => 'John Doe',
'email' => 'john@example.com',
]);
License
Released under the MIT License.