0

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!

0

1 Answer 1

1

You either include them as you mentioned, or you specify the whole namespace every time:

{!! myMethod('error', \App\Library\LayoutType::ltFrontend) !!}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.