mercredi 25 octobre 2017

Calling constant attributes of a class from laravel blade?

I have the next class.

    namespace App\Repository\Constants\Models;

class InstanceModelContant
{
    const ALREADY_DEMO = "Usted ya posee un demo.";
    const ALREADY_INSTANCE = "Ya tiene un servidor con estas caracteristicas.";
    const INSTANCE_DEMO_TYPE = "t2.micro";
    const CHAR_NOT_PUBLIC_ADDRESS = "--";
}

within the class defined several constants that I use in several places throughout the project.

in blade I have to make a comparison of the attribute of a model that would look like this

@if($instancia->publicip == '--')
                        
                    @else
                    <h1>hola mundo</h1>
                    @endif

But as I see I have to remove the code from the - what I want is to use the CHAR_NOT_PUBLIC_ADDRESS attribute inside the blade and not burn the code. Or else I could advise



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2i4lTgG
via IFTTT

Aucun commentaire:

Enregistrer un commentaire