PHPackages                             dominikstyp/laravel-model-abstractor - 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. dominikstyp/laravel-model-abstractor

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

dominikstyp/laravel-model-abstractor
====================================

Makes AbstractModel inside app/models directory, changes make:model command to generate models which inherit from AbstractModel, and provides php artisan command to move your existing models to app/models directory and change their inheritance to AbstractModel. Thanks to that all your models will inherit from your custom class.

1.0.0(8y ago)391MITPHPPHP ~7.0

Since Nov 14Pushed 8y ago1 watchersCompare

[ Source](https://github.com/DominikStyp/laravel-model-abstractor)[ Packagist](https://packagist.org/packages/dominikstyp/laravel-model-abstractor)[ RSS](/packages/dominikstyp-laravel-model-abstractor/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Laravel Model Abstractor
========================

[](#laravel-model-abstractor)

Makes **AbstractModel** inside app/models directory, changes **make:model** command,to generate models which inherit from **AbstractModel**, and provides php artisan command to move your existing models to app/models directory and change their inheritance to **AbstractModel**. Thanks to that all your models will inherit from your custom class.

Installation
============

[](#installation)

```
composer require "dominikstyp/laravel-model-abstractor @dev" -vvv
php artisan vendor:publish --provider='\\DominikStyp\\LaravelModelAbstractor\\LaravelModelAbstractorServiceProvider'

```

Laravel &gt;= 5.5
-----------------

[](#laravel--55)

Due to package discovery feature introduced in Laravel 5.5, you don't have to add service provider to your providers any more.

Laravel &lt; 5.5
----------------

[](#laravel--55-1)

For Laravel less than 5.5, you must add service provider to your **config/app.php** file, as follows:

```
 'providers' => [
    // ...
    DominikStyp\LaravelModelAbstractor\LaravelModelAbstractorServiceProvider::class,
    // ...
  ],
```

Usage
=====

[](#usage)

**Laravel Model Abstractor** provides new console tasks:
`laravel-model-abstractor:list-models` Lists all your models which inherit from **Eloquent\\Model**
`laravel-model-abstractor:change-models-inheritance` Changes default models inheritance to **AbstractModel**,
and namespaces to **App\\Models**, and moves them to **app\\Models** directory.
WARNING! This doesn't affect **User** model, because it inherits from **Authenticatable**, so you must change it manually,
along with **config/auth.php - providers section**.

Example
=======

[](#example)

Let's say you have a model file **app/Dummy1.php** which contains following code:

```
