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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners