Is there any method to check if view exists?
Like PHP file_exists, but using internal laravel method for convenience
i want to code like this:
if(__ifViewExist__($view)){ return view($view)->render(); } return "Page tidak ditemukan";
$result = User::where("email", $email)->exists(); The above clause will give true if record exists and false if record doesn't exists. So always try to use where() for record existence and not find() to avoid NULL error.
Views may also be returned using the View facade: use Illuminate\Support\Facades\View; return View::make('greeting', ['name' => 'James']); As you can see, the first argument passed to the view helper corresponds to the name of the view file in the resources/views directory.
Loading a view in the controller is easy. You just need to add `view('viewname')` method while returning from the controller method. `view()` is a global helper in Laravel. In this method, you just need to pass the name of the view.
What are the views? Views contain the html code required by your application, and it is a method in Laravel that separates the controller logic and domain logic from the presentation logic. Views are located in the resources folder, and its path is resources/views.
Yes, an exists() method is available.
if(view()->exists($view)){ return view($view)->render(); } return "Page tidak ditemukan";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With