Generic Repository Pattern implementation with laravel

Create a database in mysql

or create model by artisan command

or create model in folder

It will create Models folder and put Test in Models folder

Create a folder Repositories in app directory .

in repository

BaseInterface.php

BaseRepository.php

Lets create a model call Test.php

Create a Test folder in Repositories and create ITestRepository.php

and TestRepository.php

in AppServiceProvider.php resolve the dependency

Now i can use it on controller like this.
Lets create a controller TestController.php

and in route file add

Basic Implementation

Complete implementation

Leave a Reply

Your email address will not be published. Required fields are marked *