How to use Blade directives conditionally in Laravel

If you need to apply some css classes conditionally in your Laravel Blade templates, you can do it with the following technique: In this example we’ve created a table with different background for odd and even rows using Tailwind CSS classes.

How to include javascript files on specific pages with Blade in Laravel

There is a beautiful trick to make this happen with Laravel. First, you need to specify @stack method in your main blade file (the wrapper) or in the file for javascript includes. Second, you need to “push” from your specific page the needed javascript include. For example, we have this blade files structure: /views/main.blade.php, the […]