In Laravel 8 I use enum class app/Library/LayoutType.php :
<?php namespace App\Library {
use WBoyz\LaravelEnum\BaseEnum;
class LayoutType extends BaseEnum
{
const ltFrontend = 'frontend';
const ltAdmin = 'admin';
const ltPersonal = 'personal';
}
}
based on https://github.com/wboyz/laravel-enum extention. I try to use it in blade.php file :
{!! myMethod('error', LayoutType::ltFrontend) !!}
and I have to set lines
<?php
use App\Library\LayoutType;
?>
in the same blade.php file. I dislike it and try to avoid it,
Method myMethod
is located in file app/Library/helper.php
, which is written in composer.json
as :
"autoload": {
"files": [
"app/Library/helper.php"
],
If these is a way to use these enum in blade files? Maybe based on other class, not WBoyz\LaravelEnum ?
Thanks in advance!
CodePudding user response:
You either include them as you mentioned, or you specify the whole namespace every time:
{!! myMethod('error', \App\Library\LayoutType::ltFrontend) !!}