lopatin96/lara-enum

1.0.2 2025-03-22 17:23 UTC

This package is auto-updated.

Last update: 2025-03-22 17:25:00 UTC


README

Installation

You can install this package via composer:

composer require lopatin96/lara-enum

How to use

Publish config and local files:

php artisan vendor:publish --tag="lara-enum-config"
php artisan vendor:publish --tag="lara-enum-lang"

Config

Add key-value to lara-enum config file:

return [

    'document-status' => [
        'color' => [
            'pending' => 'amber',
            'in_progress' => 'blue',
            'in_progress_pending' => 'blue',
            'finished' => 'green',
            'error' => 'red',
        ],
    ],

];

and call $document->status->getColorProperty().

Local

Add key-value to lara-enum local file:

return [

    'document-status' => [
        'label' => [
            'pending' => 'Pending',
            'in_progress' => 'In progress',
            'in_progress_pending' => 'In progress',
            'finished' => 'Finished',
            'error' => 'Error',
        ],
    ],

];

and call $document->status->getLabelLocal().