Creates repositories for Laravel models

Overview

##Repositories Maker##

Repository pattern is an abstraction layer for your models.

Instead of writing tones of duplicated queries in your controllers.

You can make a repository that has a readable name and implements an interface(for changing the dependencies later) and bind the repository with it`s interface using the IOC container. Looks like lots of work to be done .....

Repositories Maker makes this process as easy as typing one artisan command.

1.Go to your laravel project root and type

composer require abdelrahmanrafaat/repositories-maker:dev-master

2.you need to register the package service provider .. Go to config/app.php and add this line to the end of the providers array. Abdelrahmanrafaat\RepositoriesMaker\Provider\RepositoriesMakerServiceProvider::class

3.This command should add a new command to your artisan list .. make:repositories

4.This Command Assumes that your models are at at app directory and extends Model class , but of course you can change this options as i will explain later.

php artisan make:repositories

This artisan command if you add --help to the end of it you will get the some options.

  • --parent : Specify the parent class of your models (Only the class base name not the full name space) or you can leave it blank if your models don`t extend a parent class or they extend different parent classes.

  • --directory : Directory that contains your models starting from the project root directory (this option can`t start with / Or ****).

  • --nestedDirectories : boolean option(false by default) indicates if your models are in nested directories.

  • --except : Comma seperated list of models that you don`t want to generate a repositories for.

  • --only : create repositories only for this Comma seperated list of models.

Note :

  • except and only options don`t work togther you need to specifiy one of them.
  • except and only model names are (class base name not the full name space)

5.If you run the command it will generate the repositories and interfaces in app\Repositories and RepositoriesServiceProvider in the app\Provider and the terminal will output the names of generated files.

6-you need to register the RepositoriesServiceProvider .. Go to config/app.php and add this line to the end of the providers array(make sure you change App if you have different namespace for your application).

App\Providers\RepositoriesServiceProvider::class

........

Now you are good to go , you can go to any class that has automatic resolution (controller , event , command ..) and type-hint the repository interface , and you will get a repository that has an instance of it`s model.

Happy coding ..

You might also like...
The package lets you generate TypeScript interfaces from your Laravel models.

Laravel TypeScript The package lets you generate TypeScript interfaces from your Laravel models. Introduction Say you have a model which has several p

A Laravel package for multilingual models
A Laravel package for multilingual models

Introduction If you want to store translations of your models into the database, this package is for you. This is a Laravel package for translatable m

A Laravel package for attachment files to models

Laravel attachmentable package A package for attachment files to models Installation Run the command below to add this package: composer require larav

A package to implement repository pattern for laravel models

Laravel Model UUID A simple package to use Repository Pattern approach for laravel models . Repository pattern Repositories are classes or components

Advanced Laravel models filtering capabilities

Advanced Laravel models filtering capabilities Installation You can install the package via composer: composer require pricecurrent/laravel-eloquent-f

A Laravel package making a diagram of your models, relations and the ability to build them with it
A Laravel package making a diagram of your models, relations and the ability to build them with it

Laravel Schematics This package allows you to make multiple diagrams of your Eloquent models and their relations. It will help building them providing

A Laravel Code Generator based on your Models using Blade Template Engine
A Laravel Code Generator based on your Models using Blade Template Engine

Laravel Code Generator is a PHP Laravel Package that uses Blade template engine to generate code for you. The difference between other code generators

Tag support for Laravel Eloquent models - Taggable Trait

Laravel Taggable Trait This package is not meant to handle javascript or html in any way. This package handles database storage and read/writes only.

Preferences for Laravel Eloquent models

Preferences for Laravel Eloquent models Use this library to bind multiple key/value pair preferences to your application's Eloquent models. Preference

Owner
null
A university system that creates a timetable programm for subjects,classes and teachers which is used to create a programm for each semester. All this served as a website.

Timetable-System-Generator A university system that creates a timetable programm for subjects,classes and teachers which is used to create a programm

null 3 Nov 19, 2022
Creates a Filament table action.

Filament Action Designed for easy integration and manage of Filament actions. Installation You can install the package via composer: composer require

Mitesh Rathod 10 Jun 14, 2023
Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models.

Laravel Wrapper for PostgreSQL's Geo-Extension Postgis Features Work with geometry classes instead of arrays. $model->myPoint = new Point(1,2); //lat

Max 340 Jan 6, 2023
Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel 5.

Laravel-Mediable Laravel-Mediable is a package for easily uploading and attaching media files to models with Laravel. Features Filesystem-driven appro

Plank Design 654 Dec 30, 2022
An Eloquent Way To Filter Laravel Models And Their Relationships

Eloquent Filter An Eloquent way to filter Eloquent Models and their relationships Introduction Lets say we want to return a list of users filtered by

Eric Tucker 1.5k Jan 7, 2023
Easy creation of slugs for your Eloquent models in Laravel

Eloquent-Sluggable Easy creation of slugs for your Eloquent models in Laravel. NOTE: These instructions are for the latest version of Laravel. If you

Colin Viebrock 3.6k Dec 30, 2022
Record the change log from models in Laravel

This package will help you understand changes in your Eloquent models, by providing information about possible discrepancies and anomalies that could

Owen IT Services 2.5k Dec 30, 2022
Automatically validating Eloquent models for Laravel

Validating, a validation trait for Laravel Validating is a trait for Laravel Eloquent models which ensures that models meet their validation criteria

Dwight Watson 955 Dec 25, 2022
Laravel Ban simplify blocking and banning Eloquent models.

Laravel Ban Introduction Laravel Ban simplify management of Eloquent model's ban. Make any model bannable in a minutes! Use case is not limited to Use

cybercog 879 Dec 30, 2022
cybercog 996 Dec 28, 2022