PHP code example of giacomomasseron / laravel-models-generator

1. Go to this page and download the library: Download giacomomasseron/laravel-models-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/ */

    

giacomomasseron / laravel-models-generator example snippets


return [
    'table' => true,
    'connection' => true,
    'primary_key' => true,

    'parent' => Illuminate\Database\Eloquent\Model::class,
    'namespace' => 'App\Models',

    /**
     * [
     *      'table_name' => 'polymorphic_type',
     *
     *      ex. for official laravel documentation
     *          'posts' => 'commentable',
     *
     * ]
     */
    'morphs' => [
    ],

    /**
     * Interface(s) implemented by all models
     */
    'interfaces' => [
    ],

    /**
     * Trait(s) used by all models
     */
    'traits' => [
    ],
];

'morphs' => [
    'posts' => 'imageable'
],

public function imageable(): MorphTo
{
    return $this->morphTo(__FUNCTION__, 'imageable_type', 'imageable_id');
}

public function images(): MorphMany
{
    return $this->morphMany(Image::class, 'images');
}

'interfaces' => [
],

'traits' => [
],
bash
php artisan vendor:publish --tag="laravel-models-generator-config"
bash
php artisan laravel-models-generator:generate