Laravel Blade Include File If Exists

Laravel 8 , Laravel 7 , Laravel , Laravel 6

Nicesnippets

1104

25-01-2021


Laravel Blade Include File If Exists

Hi Guys,

In this blog, I will show you how to include file if exists in laravel blade. We will talk about laravel blade include file if exists example. I am going to learn you how to include file if exists in blade in laravel application. We will show How to include blade if exists in another file?. Let see example of How to include a view.blade.php file if exists in Laravel

If you attempt to @include a view which does not exist, Laravel will throw an error. If you would like to include a view that may or may not be present, you should use the @includeIf directive:

Example


<!DOCTYPE html>

<html>

<head>

<title>Laravel Blade Include File if exists Example - NiceSnippets.com</title>

</head>

<body>

@includeIf('example.index', ['status' => 'Include file successfully'])

</body>

</html>

Include File

resources/views/example/index.blade.php

<h1>{{ $status }}</h1>

It will help you....


Recommended Posts