LaravelPackages.net
Acme Inc.
Toggle sidebar
g4t/enum

PHP Enums

5
0
0.0.1
About g4t/enum

g4t/enum is a Laravel package for php enums. It currently has 0 GitHub stars and 5 downloads on Packagist (latest version 0.0.1). Install it with composer require g4t/enum. Discover more Laravel packages by g4t or browse all Laravel packages to compare alternatives.

Last updated

Laravel Enum

This package offers strongly typed enums in PHP. In this package we will change the value coming from the database and entered into it

Installation

Via Composer

composer require g4t/enum
php artisan vendor:publish --provider=g4t\Enum\EnumServiceProvider

Usage

use the following code in model

use g4t\Enum\Status;
.
.
.

protected $casts = [
  'column_name' => Status::class,
];

now go to config/enum.php you well find this example there:

In the following code, the key is the value allowed in the database
and value is the format to be output instead of the one in the database
<?php

return [
    '1' => 'active',
    '2' => 'inactive'
];

License

MIT. Please see the license file for more information.

Comments