innoflash / laravel-design-patterns
Laravel design patterns
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^7.1.3
- laravel-zero/framework: 5.8.*
- zendframework/zend-text: ^2.7
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-10-29 06:05:37 UTC
README
Laravel Design patterns
This is a community project and not an official Laravel one
Laravel Design Patterns was created by, and is maintained by Innocent Mazando, and is console application running on composer used to create Laravel Repository and Service pattern.
Installation
Install via composer.
Note: For windows user, first run composer global update
composer global require innoflash/laravel-design-patterns
Create a repository
ldp pattern:repository {model_name}
The model_name
is the model you wanna create a repository for
eg
ldp pattern:repository Models/User
links a the App\Models\User
And likewise
ldp pattern:repository User
links App\User
Command creates the repo folder under Repositories in the model name folder
This creates an ModelEloquent file that you are gonna have to override when you are passing your app login
Also it creates an interface that`s used in the Eloquent file. You can add or remove more abstract methods to this to further customize your repo
Create a service
ldp pattern:service {model_name}
The model_name
is the model you wanna create a repository for
eg
ldp pattern:service Models/User
links a the App\Models\User
And likewise
ldp pattern:service User
links App\User
Command creates the service file Services with your model name concatenated with "Service"
This is how the service class created looks like