PHPackages                             mennovanhout/laravel-model-constants - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mennovanhout/laravel-model-constants

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mennovanhout/laravel-model-constants
====================================

This package creates constants for column names, this can then be used instead of strings to reduce typo's errors and improve coding with your IDE

v0.9.5(2y ago)12497[1 issues](https://github.com/mennovanhout/laravel-model-constants/issues)MITPHPPHP ^8.0

Since Mar 14Pushed 1y ago3 watchersCompare

[ Source](https://github.com/mennovanhout/laravel-model-constants)[ Packagist](https://packagist.org/packages/mennovanhout/laravel-model-constants)[ RSS](/packages/mennovanhout-laravel-model-constants/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (1)Versions (8)Used By (0)

Laravel Model Constants
=======================

[](#laravel-model-constants)

This package will generate constant files for your models to reduce typo's and the need of debugging to find out what attributes are available.

Benefits
--------

[](#benefits)

1. This package is ready to be installed and to forget about, no maintenance or commands you have to learn.
2. This packages listens to the Laravel migrations ended event (Files automatically get updated/generated).
3. When a column is removed you will get IDE errors.
4. Fewer typo's.
5. These constants are widely available throughout your whole codebase instead of having to type string.
6. This package is created with all design patterns in mind. Whether you use domain driven design or Laravels default approach.

How to install it
-----------------

[](#how-to-install-it)

`composer require mennovanhout/laravel-model-constants`

How to use it
-------------

[](#how-to-use-it)

This packages hooks into Laravels migration system and will generate the files after each migration or batch of migrations.

You can run it manually with: `artisan model:constants`.

If you want to remove files generated by this packages you can do that with: `artisan model:constants-clean`.

Example: Generated constant file
--------------------------------

[](#example-generated-constant-file)

```
