Download the PHP package asb/morphmtm without Composer
On this page you can find all versions of the php package asb/morphmtm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package morphmtm
Short Description This package provides you with a module to automatically files need (Model,Migrations,...) add Morph many-to-many relations to your project along with commonly used basic commands.which minimizes the trial and error operation for you..
License MIT
Informations about the package morphmtm
Feature
Maybe for you, implementing a series of models and repetitive relationships is boring, time-consuming and annoying, and you will have to copy your previous codes or refactor them, which will be a waste of time.\ This package provides you with a module to automatically files need (Model,Migrations,...) add Morph many-to-many relations to your project along with commonly used basic commands.\ which minimizes the trial and error operation for you.
how to use this package :
There is no need to define relationships anymore, and it is enough to Add the necessary Trait Has+yourModel (like this => hasStatus) in the models to which the Model is applied.
Requirements
The package requires PHP 8 or higher. The Laravel package also requires Laravel 10 or higher.
Quick Start
-
Installation:
`
-
publish the package's configuration file by running:
`
-
Autoloading
By default, the module classes are not loaded automatically. You can autoload your modules using _psr-4_. For example:
"autoload": { "psr-4": { "App\": "app/", "Rack\": "Rack/" } }
Tip: don't forget to run composer dump-autoload afterward\
In an example to create a category module, I will explain how to use it.
-
build module:
php artisan mtm:build *Modulename*
in continue the command, you will be asked to named, of course, you can confirm and pass the default value by pressed the enter key, but some default words may not be to your liking.`
Tip: If You need to remove a module you can use this command \ php artisan mtm:remove ModuleName
-
Add the necessary Trait to your model:
``
-
Use predefined functions:
-
it gets all the models that have Category.
Tip: all functions is can call static with this format (MTM+modelName):\
one example : MTMCategory::getModelsHave('new')
``
-
it gets all the Categories of Model.
``
-
it checks the Model has this Category by Title or ID.
``
-
it assigns a Category to the Model by Title or ID.
``
-
it adds a Category to the Model by Title or ID.
``
-
it updates a Category from the Model and replace by new Category Or a Category that exists.
``
-
it removes a Category from the model by Title or ID.
``
-
it removes all Categories from the model.
``
-
-
Using CRUD of Model in Module:
-
it Creates a Category by a new Title.
``
-
it gets all of Category And if it is called with "true" parameter, it will get all the deleted Category.
``
-
it gets a Category by Title or ID.
``
-
updates a Category by Title or ID and replace by a new Title
``
-
it removes a Category by Title or ID and removing the Category and from all Models.
``
-
it restored a Category by Title or ID.
``
-