1. Go to this page and download the library: Download lucastuzina/laranums library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lucastuzina / laranums example snippets
use Lucastuzina\Laranums\Laranum;
enum Status: string
{
use Laranum;
case Active = 'active';
case Inactive = 'inactive';
case Pending = 'pending';
}
Status::fromValue('active'); // Status::Active
Status::toSelectOptions(); // ['active' => 'Active', 'inactive' => 'Inactive', …]
Status::Active->next(); // Status::Inactive
Status::Active->in([Status::Pending]); // false
use Lucastuzina\Laranums\Attributes\{Label, Color, Icon};
enum OrderStatus: string
{
use Laranum;
#[Label('Pending'), Color('yellow'), Icon('clock')]
case PENDING = 'pending';
#[Label('Paid'), Color('green'), Icon('check-circle')]
case PAID = 'paid';
}
OrderStatus::PAID->color(); // 'green'
OrderStatus::toSelectOptions(); // ['pending' => 'Pending', 'paid' => 'Paid']
use Lucastuzina\Laranums\Concerns\{HasLookup, HasAttributes};
enum MyEnum: string
{
use HasLookup, HasAttributes;
// ...
}
sh
php artisan make:laranum UserRole admin editor guest --type=string --lang=en,de
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.