Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 6 days ago
JSON representation

Package that let's you Implement repository pattern with a single command

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.