This Laravel package will generate models with their appropriate Eloquent relations based on an existing database schema.
For automatically generating database migrations for your schema, see kitloong/laravel-migrations-generator
- PHP 8.1+
- Laravel 8+
You can install the package via composer:
composer require --dev pepijnolivier/eloquent-model-generator
You can publish the config file with:
php artisan vendor:publish --tag="eloquent-model-generator-config"
This is the contents of the published config file:
<?php
use Illuminate\Database\Eloquent\Model;
return [
/*
|--------------------------------------------------------------------------
| Namespace
|--------------------------------------------------------------------------
|
| The default namespace for generated models.
|
*/
'model_namespace' => 'App\Models\Generated',
'trait_namespace' => 'App\Models\Generated\Relations',
/*
|--------------------------------------------------------------------------
| Output Path
|--------------------------------------------------------------------------
|
| Path where the models will be created.
|
*/
'model_path' => 'app/Models/Generated',
'trait_path' => 'app/Models/Generated/Relations',
/*
|--------------------------------------------------------------------------
| Extend Model
|--------------------------------------------------------------------------
|
| Extend the base model.
|
*/
'extend' => Model::class,
];
php artisan generate:models
composer test
Please see CONTRIBUTING for details.
Please see SECURITY for details.
The MIT License (MIT). Please see License File for more information.