Laravel check view file exist or not in folder?

Laravel

Nicesnippets

4720

02-05-2020


Hello Friends,

Sometime we generate dynamic view blade file at that time we call view file check before. and also it's good check file available or not in folder. how to check if file exists in laravel.

Check In Controller,Model,Repository,Helper


use Illuminate\Support\Facades\View;

public function index()

{

if (View::exists('auth.login')) {

//

}

}

Check In View Blade

@if(\View::exists('auth.login'))

...

@endif

I hope it can help you...