If you're dealing with views in Laravel directly and need to check if a view exists beforehand, here how.
It's super simple! Just use the exists
method on the View
class. Here, I'm doing this via the view
helper.
if (view()->exists('some.view')) {
//...
}
Bear in mind that some.view
means /some/view.blade.php
. This method works the same with dot notation as you'd use when rendering views.