Link:  https://meramustaqbil.com/2019/03/09/how-to-transform-your-php-to-javascript-laravel/

Often, you find yourself in a situation where you want to pass your server-side variables, string, collection to JavaScript. By traditional old ways it can be a bit of pain especially when your application grows.

laravel variables

In this tutorial I will guide on how to pass php variable to JavaScript, elegantly. For this purpose, Jeffery Way from Laracasts has created a package called utilities with following name space: laracasts/utilities.