robincode
robincode

Reputation: 590

Blade: How to include default view If include view error?

I want to @include('item_1'), if not the item_1 view then @include('default').

Idk how to include default view.

My laravel version is 5.2.

Upvotes: 1

Views: 113

Answers (2)

Alexey Mezenin
Alexey Mezenin

Reputation: 163778

You can try exists() method:

@include(View::exists('item_1') ? 'item_1' : 'default')

Upvotes: 1

jeanj
jeanj

Reputation: 2166

@if (View::exists('item_1'))
   @include('item_1')
@else
   @include('default')

Just use a if statement

Upvotes: 0

Related Questions