Reputation: 1941
As Laravel shipped with Vue Js framework,
I need to set a global variable to be accessible by Laravel as Backend, Also VueJs as Frontend to access it.
Both may change the value of this Global Variable. and Vue can pass it via api requests to Laravel.
I know that i can set it in .env file, So Vue can access it by process.env.VarName and Laravel can access it using method env('VarName') But it this case I can't change it in the run-time.
Upvotes: 3
Views: 1566
Reputation: 1789
You can do:
let window.something = {{ config('something') }}
On the top of your main template - but as far as preimplemented 'declare once, available everywhere' - there is no such functionality implemented (as far as I know)
Upvotes: 3