However, we know the Laravel framework is having the largest community. Similarly, Laravel having large package base. So, sometimes it is easy to use package rather use custom code. Moreover, you can use existing packages.
Just copy below package and paste into the composer.json file.
Or similarly from command line or terminal run command:
composer require laracasts/utilities
Finally, publish the config using the below command.
Now, your controller will look like below.
Now, your blade file will look like below.
console.log(Laracasts.foo); // access foo variable console.log(Laracasts.user);// access user variable console.log(Laracasts.time);// access time variable
In this way, you can directly access the set variable. This will give simple access for getting value into the js file. There is a limitation for getting the value into the js file. So this package will give you direct access into js file.
In many cases, this will give you the simplest solution. Many developers have to face this problem in developement. So, this post will give some relief from this problem. Let me know if you face any issue.
Thanks For Visiting, Keep Visiting. If you liked this post, share it with all of your programming buddies!
As a top **PHP Web Application Development Company in USA**[https://www.dataeximit.com/php-development-services/](https://www.dataeximit.com/php-development-services/ "https://www.dataeximit.com/php-development-services/"), we at Data EximIT have...
PHP - Hypertext pre-processor, a scripting language used by many people in developing web pages, but most of us are unaware even of the full form. To train someone and make them learn this whole language is as difficult and time-consuming as it is...
PHP is widely used open-source scripting language it helps in making dynamically easy your websites and web application. Mobiweb Technology is your best technical partner and offering you solution for any kind of website and application...
Among the list of Best Laravel development companies, TopDevelopers has chosen the most acclaimed laravel developers for the visitors so as to make them avail the extremely wonderful service ever offered. The web development companies listed here...
Throughout my career, a multitude of people have asked me <em>what does it take to become a successful developer?</em>