https://github.com/salmanzafar949/laravel-repository-pattern
Package that let's you Implement repository pattern with a single command
https://github.com/salmanzafar949/laravel-repository-pattern
laravel laravel5 php php7
Last synced: 14 days ago
JSON representation
Package that let's you Implement repository pattern with a single command
- Host: GitHub
- URL: https://github.com/salmanzafar949/laravel-repository-pattern
- Owner: salmanzafar949
- Created: 2019-08-20T13:27:56.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-17T04:01:40.000Z (over 3 years ago)
- Last Synced: 2025-06-22T18:08:08.186Z (5 months ago)
- Topics: laravel, laravel5, php, php7
- Language: PHP
- Homepage: https://packagist.org/packages/salmanzafar/laravel-repository-pattern
- Size: 9.77 KB
- Stars: 8
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Laravel Repository Pattern Implementation
A simple Laravel 5 and laravel 6 library that allows you to implement Repository Pattern with a single command
## Installation
```
composer require salmanzafar/laravel-repository-pattern
```
## Features
Will generate all the functionality for Repository pattern implementation
* ServiceClass
* Interface
* ServiceProvider
## Enable the package (Optional)
This package implements Laravel auto-discovery feature. After you install it the package provider and facade are added automatically for laravel >= 5.5.
## Configuration
Publish the configuration file
This step is required
```
php artisan vendor:publish --provider="Salman\RepositoryPattern\RepositoryPatterServiceProvider"
```
## Usage
After publishing the configuration file just run the below command
```
php artisan make:repo ModelName
```
That's it, Now you've successfully implemented the repository pattern
## Example
```php
php artisan make:repo Car
```
#### CarRepositoryInterface.php
```php
update($data);
}
}
```
##### Now go to
```Repositories/RepositoryBackendServiceProvider.php```
and register the interface and class you have'just created
```php
app->bind(
/*
* Register your Repository classes and interface here
**/
'App\Repositories\CarRepositoryInterface',
'App\Repositories\CarRepository'
);
}
}
```
##### And now in your ```app/Http/Controllers/Carcontroller```
```php
$car = $car;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$data = $this->car->all();
return $data;
}
}
```
##### That's it you've successfully implemented Repository pattern in your code.