Category: Laravel, PHP, javascript

Often you’d come across a scenario where you’d like to check the application environment and based on that you’d like to render things. For instance, you’d like to check if the environment application currently running in is “production”, you can verify it in the view like so. Now, this is alright that we’re leveraging the App::environment method to identify the environment of the application and it even works fine but it’s kind of verbose as you can see.

If you want to check for multiple environments in a single conditional, you can do it like so.

Follow me on Twitter @amit_merchant Check for the application environment in Laravel views How to check if the API call is failing using Fetch in JavaScript Creating your own custom conditional directives in Laravel Blade Things to consider before using arrow functions in JavaScript Remove event listener once it's invoked in JavaScript
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners