The base for the repository pattern we use in Kodebyraaet.
Install composer dependency.
composer require kodebyraaet/pattern
If you are using Laravel add the Service Provider to the config/app.php file.
Kodebyraaet\Pattern\BaseRepositoryServiceProvider::class,
If you are using Lumen add the Service Provider to the bootstrap/app.php file.
$app->register(Kodebyraaet\Pattern\BaseRepositoryServiceProvider::class);
If you have the Kodebyraaet Generators installed you can just run the following command:
php artisan make:base-repository
Or you can do it manually:
<?php
namespace App\Entities;
use Kodebyraaet\Pattern\BaseRepository;
class Repository extends BaseRepository
{
}
<?php
namespace App\Entities;
use Kodebyraaet\Pattern\BaseRepositoryInterface;
interface RepositoryInterface extends BaseRepositoryInterface
{
}
Check out Kodebyraaet Generators for a easier way to create the structure that extends this repository pattern.