PHP code example of amon / laravel-module-generator

1. Go to this page and download the library: Download amon/laravel-module-generator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

amon / laravel-module-generator example snippets

bash
php artisan module-generator:make Invoice \
    --field=number:string:unique \
    --field="status:enum(draft,sent,paid):default=draft" \
    --field="amount:decimal(12,2)" \
    --field=issued_at:date \
    --field=attachment:file:nullable \
    --relation=belongsTo:Client \
    --relation=belongsToMany:Tag:pivot=generate:form \
    --icon=file-text

php artisan migrate
npm run build
bash
# Arbre (Nested Set) : liste indentée, parent différent de soi-même et de ses descendants
php artisan module-generator:make Category --field=name:string --tree

# Polymorphe : select du type puis de l'élément ; colonne affichée par type (name par défaut)
php artisan module-generator:make Comment --field=body:text --morph=commentable --morph-types=Client,Invoice:number

# Module pivot : vrai module reliant deux modèles, unicité du couple
php artisan module-generator:make "Client tag" --pivot-of=Client,Tag --field=note:string:nullable
bash
php artisan module-generator:remove invoices                     # fichiers modifiés conservés
php artisan module-generator:remove invoices ---archived]