How to Pass PHP Variable to JavaScript in Laravel

Sometimes, you may need to pass certain PHP variables to JavaScript code in a Blade template or even to a separate JavaScript file that is imported into the template. In this short article, I will show you how to pass PHP variable to JavaScript in Laravel and avoid errors in the JavaScript console. How to … Read more

How to Redirect with Message in Laravel

Redirecting to the previous page after doing an action is common practice in Laravel projects. However, If there is an error while performing the action, you need to inform the user about it. You can return the result in the API response if creating a SPA application. Although, if you have an application rendered using … Read more

How to Use Script in Blade Laravel

If you place JavsScript code directly into the content section of the Blade template in Laravel with Vue 2, you will most likely see an error in the JavaScript console. The thing is that all JavaScript code should be in app.js and bootstrap.js. And blade files should contain only HTML code and rendering instructions. Sometimes, … Read more