how to set in laravel blade the display of a tag p depending on whether the data passed has a value or is empty or null

Viewed 36

As already described, I want to display the input in my show depending on whether the data present in the view has a value (so it is shown to me through a p tag) or do not show this p tag if the present data is null or empty.

If it is empty or null do not show anything

This is my code:

<div>
    <h4>Code</h4>
    <p>{{$client->code}}</p>
</div>
1 Answers

If I understand your question correctly, the simplest way would be to wrap it in an if statement:

<div>
    <h4>Code</h4>
    @if(!empty($client->code))
        <p>{{ $client->code }}</p>
    @endif
</div>
Related