Often times you will come across to check what is the current environment in your application. I am talking about if it’s in production or development or any other state that you defined.
For example, you may need to show Google ads on your website when it’s in production mode. Indeed, you need a directive to decide which environment you are currently in.
In Laravel, you can simply use the below code in the blade template
@production Your production code @endproduction
Or
@if(App::environment('production')) //Your Google adsense code here @endif
What if you are in a controller, you can use the below
if(config('app.env') == 'production') { //Your production code here }
Did this post help you?
Tutsplanet brings in-depth and easy tutorials to understand even for beginners. This takes a considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.
Leave a Reply