jrock2004
jrock2004

Reputation: 3501

Laravel 5 New Env variable and use in layout file

So I am trying to add a new environment variable and use it in the layout file so I can hide part of menu if registration is disbled

.env

ALLOW_REGISTRATION=FALSE

layouts/apps/blade.php

@if (env('ALLOW_REGISTRATION',TRUE))
      ...

Error I am getting

Trying to get property of non-object (View: /home/jj/Development/app/resources/views/layouts/app.blade.php) (View: /home/jj/Development/app/resources/views/layouts/app.blade.php)

Thoughts?

Upvotes: 1

Views: 535

Answers (1)

Vahe Galstyan
Vahe Galstyan

Reputation: 1731

Try php artisan serve and check again. The function env() does not gets the values from the .env file when called.

Upvotes: 1

Related Questions