PHPackages                             triun/laravel-model-base - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. triun/laravel-model-base

ActiveLibrary[Database &amp; ORM](/categories/database)

triun/laravel-model-base
========================

Generate Eloquent Model Bases for Laravel

v9.1.0(3y ago)29.1k[4 issues](https://github.com/Triun/laravel-model-base/issues)[1 PRs](https://github.com/Triun/laravel-model-base/pulls)MITPHPPHP ^8.0.2

Since Feb 27Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Triun/laravel-model-base)[ Packagist](https://packagist.org/packages/triun/laravel-model-base)[ Docs](https://github.com/Triun)[ RSS](/packages/triun-laravel-model-base/feed)WikiDiscussions 9.x Synced 3w ago

READMEChangelog (10)Dependencies (16)Versions (43)Used By (0)

Laravel Model Base
==================

[](#laravel-model-base)

[![Latest Stable Version](https://camo.githubusercontent.com/6b7ca9d0268bcfe65f8144eb83fdf8b7d19e7280be7e87b7bd9064efec468d52/68747470733a2f2f706f7365722e707567782e6f72672f747269756e2f6c61726176656c2d6d6f64656c2d626173652f762f737461626c65)](https://packagist.org/packages/triun/laravel-model-base)[![Latest Version on Packagist](https://camo.githubusercontent.com/547db26b3c14a7eafeb9f7429266c713187dc1f8a37da457478447265e442bf1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f747269756e2f6c61726176656c2d6d6f64656c2d626173652e737667)](https://packagist.org/packages/triun/laravel-model-base)[![Pre Release Version on Packagist](https://camo.githubusercontent.com/8db4f6eca53d32328b3cfd93fcf6aadc6484d2b57d0dd61ddd0ce19c367ae932/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f747269756e2f6c61726176656c2d6d6f64656c2d626173652e737667)](https://packagist.org/packages/triun/laravel-model-base)[![Latest Unstable Version](https://camo.githubusercontent.com/c9b6e66e6ae186b0ab03b88f096b42d4b1a94d6e4457161de0a23fea018557cd/68747470733a2f2f706f7365722e707567782e6f72672f747269756e2f6c61726176656c2d6d6f64656c2d626173652f762f756e737461626c65)](https://packagist.org/packages/triun/laravel-model-base)[![Build Status](https://camo.githubusercontent.com/3e4e20620572282849cf5d05bfca8bf5f01f9db4057dc982685dd50219dce0d9/68747470733a2f2f7472617669732d63692e6f72672f547269756e2f6c61726176656c2d6d6f64656c2d626173652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Triun/laravel-model-base)[![Total Downloads](https://camo.githubusercontent.com/b515e9ad2370705ce28c27d1911ab09d420f40406ad22791a907dc4bb78ba330/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f747269756e2f6c61726176656c2d6d6f64656c2d626173652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/triun/laravel-model-base)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Generate Eloquent Model Base for Laravel.

About
-----

[](#about)

Laravel-Model-Base is a Laravel command to perform repetitive tasks while creating new models, and saving it into a abstract model base, so you can update it any time, without need to worry about overwriting your manual changes in the model.

The main goal of the model base it's generate eloquent configurations based on the database table architecture, meaning that it could not be any business logic implemented, or any other logic not comming from the database itself. If you are interested in adding extra properties, methods, interfaces or traits, you can do so in the model itself.

This generator can be customised by the config parameters, but it can also be extended by the [modifiers](#modifiers).

The model will be optionally generated too, but in this case, it will never be able to be overwritten by this tool.

Installation
------------

[](#installation)

Require this package with composer using the following command:

```
composer require --dev triun/laravel-model-base
```

After updating composer, add the service provider to the providers array in config/app.php

```
Triun\ModelBase\ModelBaseServiceProvider::class,
```

### Development only installation

[](#development-only-installation)

To install this package on only development systems, add the `--dev` flag to your composer command:

```
composer require --dev triun/laravel-model-base:dev-master
```

Instead of adding the service provider in the `config/app.php` file, you should add the following code to your `app/Providers/AppServiceProvider.php` file, within the `register()` method:

```
public function register()
{
    if ($this->app->environment() !== 'production') {
        $this->app->register(\Triun\ModelBase\ModelBaseServiceProvider::class);
    }
    // ...
}
```

This will allow your application to load the Laravel Model Base on non-production environments.

Usage
-----

[](#usage)

To create one model base

```
php artisan make:mode-base table_name [--connection connection_name]
```

For Bulk creation

```
php artisan make:mode-base-bulk [--connection connection_name]
```

Note: If you don't set up the connections in the config file (`model-base.bulk.connections`), it will try to run all available connections from your database config file (`database.connections`).

Customize
---------

[](#customize)

You can publish the configuration file into your app with:

```
php artisan vendor:publish --provider="Triun\ModelBase\ModelBaseServiceProvider" --tag=config
```

Lumen
=====

[](#lumen)

If you are using Lumen, you may need to do some manual steps...

Copy the config file into your `config` directory:

```
cp vendor/triun/laravel-model-base/config/model-base.php config/
```

And you may also need to uncomment the following lines in `bootstrap/app.php` file:

```
