PHP code example of roundly-consulting / enums-for-laravel
1. Go to this page and download the library: Download roundly-consulting/enums-for-laravel 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/ */
roundly-consulting / enums-for-laravel example snippets
use RoundlyConsulting\Enums\Helpers;
enum NewsCategory: string
{
use Helpers;
case HotNews = 'hot-news';
case RegularNews = 'regular-news';
case PrivateNews = 'private-news';
}
NewsCategory::HotNews->label(); // "Hot News", translated through lang/*.json
NewsCategory::values()->all(); // ['hot-news', 'regular-news', 'private-news']
NewsCategory::toArray(); // ['hot-news' => 'Hot News', …] for a <select>
NewsCategory::options(); // EnumOption DTOs: value, label, name
$request->validate([
'category' => ['
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.