Including sub-views
The directive @include
Blade allows you to include a view of Blade inside another view. All variables that are available for viewing in Parent will be made available for viewing.
<div>
@include('shared.errors')
<form>
<!-- Form Contents -->
</form>
</div>
Even if the included view inherits all data available in the parent view, you can also pass an extra data array to the included view:
@include('view.name', ['some' => 'data'])
Of course, if you try a view that doesn’t exist, the Laravel will throw an error. If you would like to include a view that may or may not be present, you should use the directive: @includeIf
@includeIf('view.name', ['some' => 'data'])
If you would like to include, depending on a particular boolean condition, you can use the directive:
@includeWhen
@includeWhen($boolean, 'view.name', ['some' => 'data'])
To include the first display that exists of a particular array of views, you can use the directive:
@includeFirst
@includeFirst(['custom.admin', 'admin'], ['some' => 'data'])
Source: Official documentation of the Laravel
I believe the most appropriate approach would be:
@includeWhen(Auth::user()->mostrarMensagem, 'view.name');
That way you will only include this view if the variable is true
Take a look at this link from documentation of the Laravel, I believe that’s what you need.
– Alvaro Alves