innoflash/laravel-design-patterns

Laravel design patterns

dev-master 2019-08-31 12:18 UTC

This package is auto-updated.

Last update: 2024-10-29 06:05:37 UTC


README

Laravel Design patterns

Build Status Quality Score Total Downloads Latest Stable Version License

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

Repo folder

This creates an ModelEloquent file that you are gonna have to override when you are passing your app login

Repo Eloquent

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

Repo Interface

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"

Service file

This is how the service class created looks like

Service stub