PHP code example of axn / laravel-models-generator

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

    

axn / laravel-models-generator example snippets


'providers' => [
    // ...
    Axn\ModelsGenerator\ServiceProvider::class,
],

// "comments" table
class Comment extends Model
{
    // "belongs to" relation to "users" via "user_id"
    public function user() {}

    // "belongs to" relation to "users" via "updator_id"
    public function updator() {}
}

// "users" table
class User extends Model
{
    // "has many" relation to "comments" via "user_id"
    public function comments() {}

    // "has many" relation to "comments" via "updator_id"
    public function commentsViaUpdatorId() {}
}
sh
// config
php artisan vendor:publish --tag=models-generator.config

// stubs
php artisan vendor:publish --tag=models-generator.stubs

php artisan models:generate