PHP code example of osama-98 / laravel-enum-translatable
1. Go to this page and download the library: Download osama-98/laravel-enum-translatable 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/ */
osama-98 / laravel-enum-translatable example snippets
enum OrderStatusEnum: string
{
use EnumTranslatable;
case PENDING = 'pending';
case SHIPPED = 'shipped';
case DELIVERED = 'delivered';
}
return [
/*
|--------------------------------------------------------------------------
| Supported Locales
|--------------------------------------------------------------------------
| The locales that allTrans() will return translations for.
*/
'supported_locales' => ['en'],
/*
|--------------------------------------------------------------------------
| Modular Support
|--------------------------------------------------------------------------
| Enable this if you use a module system such as nWidart/laravel-modules.
| Translations will be loaded from each module's namespace automatically.
*/
'modular_enabled' => false,
/*
|--------------------------------------------------------------------------
| Namespace Resolver
|--------------------------------------------------------------------------
| The class responsible for resolving a module's translation namespace.
| Extend TranslationNamespaceResolver to customize the resolution logic.
*/
'namespace_resolver' => \Osama\LaravelEnums\TranslationNamespaceResolver::class,
];
namespace App\Enums;
use Osama\LaravelEnums\Concerns\EnumTranslatable;
enum CourseStatusEnum: string
{
use EnumTranslatable;
case DRAFT = 'draft';
case PENDING = 'pending';
case PUBLISHED = 'published';
}