Looking to hire Laravel developers? Try LaraJobs

laravel-base-repository maintained by viniciusjpsilva

Description
A reusable base repository implementation for Laravel.
Last update
2026/07/18 15:46 (dev-main)
License
Links
Downloads
0

Comments
comments powered by Disqus

Laravel Base Repository

Latest Version on Packagist Total Downloads PHP Laravel License

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.