wekode/repository

Repository pattern setup

v0.5.0 2021-12-05 08:47 UTC

This package is auto-updated.

Last update: 2025-07-05 16:41:18 UTC


README

This is a package to easely integrate a repository pattern with the needed service provider and all the necessary basic functions

Installation

Require this package with composer. It is recommended to only require the package for development.

composer require wekode/repository

Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

Laravel without auto-discovery:

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

Wekode\Repository\RepositorySetupServiceProvider,

Copy the package main files and setup your repository with the publish command:

php artisan vendor:publish --provider="Wekode\Repository\RepositorySetupServiceProvider"

Usage

This package comes with a command that creates the repositories and contracts, as well as the model if it does not exist.

php artisan make:repository Post

This command will create a repository file, a contract file and links the in the RespositoryServiceProvider. PS: the used model will be the first word of the Repository file name (ex : PostRepository will be linked to the model Post)

In case the model does not exist you can use this command

php artisan make:repository Post -m

This command will create the repository as well as execute a model creation command

php artisan make:model Post -a

Or if you do not want to create everything you can specify the option.

php artisan make:repository PostRepository -m -s -f -r