PHPackages                             safiullahsarhandi/laravel-repository - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. safiullahsarhandi/laravel-repository

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

safiullahsarhandi/laravel-repository
====================================

This Package is used to implement repository pattern in laravel with very minimal code

1.0.5(2y ago)71.2k1proprietaryPHPPHP ^8.0

Since Nov 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/safiullahsarhandi/laravel-repository)[ Packagist](https://packagist.org/packages/safiullahsarhandi/laravel-repository)[ RSS](/packages/safiullahsarhandi-laravel-repository/feed)WikiDiscussions master Synced today

READMEChangelog (5)DependenciesVersions (7)Used By (0)

This Package is used to implement repository pattern in laravel with very minimal code. Idea behind this implementation is to allow modular approach and reusable every single entity in your project and enhance your coding experience with features like model binding, repository generator, repository events etc.

Installation
------------

[](#installation)

using below mentioned command you can add this package in your laravel project

`composer require safiullahsarhandi/laravel-repository`

after installing this package you need to register provider `LaravelRepository\Providers\RepositoryServiceProvider::class,` in your project's `config/app.php`

publish assets
--------------

[](#publish-assets)

1. `php artisan vendor:publish --tag=repository-config`this command will create `repository.php` configuration file in `config` directory which will store information like this this.

```

```

Usage
-----

[](#usage)

This package offers few commands which helps to perform different tasks or you can say that it's required to use this.

1. How to Create Repository

    command: `php artisan make:repository  `

    creating repository would be easy by using this package. it register your repository in config file. and create set of files in app\\Repositories directory, for instance `php artisan make:repository User/UserRepository User` will update your `app\Repositories` folder like this

    [![repository-dir](https://user-images.githubusercontent.com/36722999/199682649-8fa5718e-40c7-4371-ae6a-1d48931ec897.png)](https://user-images.githubusercontent.com/36722999/199682649-8fa5718e-40c7-4371-ae6a-1d48931ec897.png)

    and update your config file like this

    ```

    ```
2. Create Query Filter

    idea behind filter is to extend database query. When calling any specific repository, every repository function which you will see below has some how similar structure and contain minimum amount of code. i will explain implementation for filters in next section of documentation so that you will get familier with it but for now let's check how to generate query filters with given command.

    command: `php artisan make:filter `

    eg: `php artisan make:filter Api/UserFilter` this will generate filter in `app/Filters/Api/UserFilters.php`

    [![filter-dir](https://user-images.githubusercontent.com/36722999/199750595-0a7a8b04-d830-4584-893c-7ee6c3f9d763.png)](https://user-images.githubusercontent.com/36722999/199750595-0a7a8b04-d830-4584-893c-7ee6c3f9d763.png)

    this will be final output for `make:filter` command.

    ```
