How to get laravel .env variable in blade or controller?

I am working on a laravel project, where I set some variables in the .env file. Now how can I access them in the blade template or controller?
Variables are:

APP_KEY="pufimebradr481u3it9l"
APP_SECRET="tr1wu7lyujupr8truperojuhlxedu81a"

You can simply use env() helper function to access env file variable. Both blade template and controller have access to the env() helper function so we can safely use it in both places.

Blade Template Example

@if ( env('APP_KEY') )
    do something with the APP_KEY
@endif

Controller Example

if ( env('APP_SECRET') ){
    // do something with the APP_SECRET
}

Hope this solves your problem.