Download the PHP package mohammadmehrabani/repository-generator without Composer
On this page you can find all versions of the php package mohammadmehrabani/repository-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mohammadmehrabani/repository-generator
More information about mohammadmehrabani/repository-generator
Files in mohammadmehrabani/repository-generator
Package repository-generator
Short Description Quickly generating repository and interfaces from existing model files
License MIT
Informations about the package repository-generator
Laravel - Repository Generator
About
Repository Generator is a Laravel package that aims to generate repository and interface files and binding interfaces to implementations automatically for repository pattern. It gives you developing speed by automated operations. You can use this package for both ongoing and new projects.
- Highly customizable with simple config
- Overriding option
- Easy to improve
Installation
You can install the package via Composer:
Next, you must install the service provider to config/app.php
:
Then, if you want to customize folder names, namespaces, etc... You need to publish config with command:
Now you can edit config/repository-generator.php
Usage
Before using generate
commdand you should customize config/repository-generator.php
for your own use.
You can simply use repository:generate
command by terminal:
Next, you must install the service provider to config/app.php
:
Repository file provided by RepositoryGenerator (optional use)
This package contains Repository.php which has similar functions to Eloquent. You can basically do something like below when you extend class from \MohammadMehrabani\RepositoryGenerator\Repository
This is completely personal and optional. I just created/copied some functions from Eloquent to add similar functionalities directly to repository file. So I can use same methods in my controller If I extend or implement this repository/interface for other database source like mongodb.
Built-in active() scope
Available Methods
All listed methods have same usage as Eloquent
Method | Usage |
---|---|
select | $repo->select('column1,'column2') |
$repo->select(['column1, 'column2']) | |
active | $repo->active()->get(); |
active() is equal to $repo->where('active_column', 1); | |
where | $repo->where('column', 'value')->first(); |
$repo->where('column', '>', 10)->first(); | |
whereIn | $repo->whereIn('column', ['value1', 'value2'])->get(); |
orWhere | $repo->orWhere('column', 'value')->first(); |
with | $repo->with('relation')->get(); |
count | $repo->where('column', 'value')->count(); |
find | $repo->find($id); |
$repo->find($id, ['column1', 'column2']); | |
first | $repo->first(); |
$repo->first(['column1', 'column2']); | |
value | $repo->where('id', $id)->value('name'); |
orderBy | $repo->orderBy('column')->get(); // default 'asc' |
$repo->orderBy('column', 'desc')->get(); | |
get | $repo->get(); |
$repo->get(['column1', 'column2']); | |
paginate | $repo->paginate(20); |
create | $repo->create(['column1' => 'value', 'column2' => 'value']); |
update | $repo->update($id, ['column1' => 'value', 'column2' => 'value']); |
delete | $repo->where('column', 'value')->delete(); |
$repo->delete($id); | |
destroy | $repo->destroy($id); |
Contributing
Thank you for considering contributing to the Repository Generator! The contribution guide can be found in the CONTRIBUTING.md
All versions of repository-generator with dependencies
illuminate/console Version ~5.0|~6.0|~7.0|^8.0