Embed logic directly into your HTML In the last article we covered the @class and @style directives to implement conditional styling in Blade. But, there are other HTML attribute directives that are present in Blade that we can utilize: @checked directive @selected directive @disabled directive @readonly directive @required directive @checked directive With the @checked directive, the radio button or checkbox will be checked if the condition is truthy. Route::get(‘/directive-test’, function () { return view(‘html-directives.index’, [‘isActiveVar’ => true]); }); The $isActiveVar variable is set to true and passed to the html-directives.index Blade file. <label for=”isActive”>Is Active?</label> <input type=”checkbox” id=”isActive” name=”isActive” value=”isActive” @checked( old(‘isActive’, $isActiveVar) ) /> Inside the Blade file, the @checked directive accepts an argument that will be truthy.
Articles
Style smart, render dynamic With Blade Components, conditional styling refers to the ability to add different styles to HTML elements based on certain conditions. Blade provides several conditional directives that can be used to accomplish this. The @if directive can be used to conditionally apply styles to an element based on a specific condition. For example, to apply a different background color to an element based on a variable value, you could use: @if ($showRed) <div style=”background-color: red;”> Red Background </div> @else <div style=”background-color: blue;”> Blue Background </div> @endif We can test this with the following route: Route::get(‘/conditional-styling’, function () { return
Artificial intelligence may be the hottest topic in boardrooms, but how prepared are companies really? Recent surveys paint a sobering picture of organizational AI literacy and readiness. Despite heavy buzz and investment, most companies, and their people, are still in the early stages of understanding and adopting AI. In this segment, we’ll break down the latest data on how well executives and employees grasp AI, how trained the workforce is, the rise (or lack) of formal AI roles, and how different regions of the world compare. Executive Hype vs. Employee Reality There’s a clear gap between leadership perception and on-the-ground
Environment checks made simple There comes a time when you want to use environmental variables in your Blade components. But, how do you do it? There are a couple of different ways. We’ll take a look at the env() function first and then the directive itself. https://www.dinocajic.com/laravel-p64-rendering-jason-in-blade/ Using the env() function Let’s open our .env file and take a look at some of the variables that are already defined there. APP_NAME=Laravel APP_ENV=local APP_KEY=base64:X2mYdNpqK29Z21Fb9Dx6PDa6Jwd6k4ThXuP+VYd9dco= APP_DEBUG=true APP_URL=http://laravel-tutorials.test LOG_CHANNEL=stack LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug DB_CONNECTION=mysql DB_HOST=mysql DB_PORT=3306 DB_DATABASE=laravel_tutorials DB_USERNAME=sail DB_PASSWORD=password We can access any of those variables with our env() function. Create a new Blade file and a route to access it.
As an observer of the AI industry, I’ve been struck by how rapidly the landscape is evolving – not just in model capabilities, but in the hardware and infrastructure that underpin these advances. The last few months have seen record-breaking AI chip performance , new approaches to data center design (to handle unprecedented power and cooling demands), and a growing spotlight on the energy footprint of large-scale AI. Below, I’ve compiled a rundown of key developments from late 2024 through spring 2025. AI Chip Performance: Faster and More Efficient Than Ever The market for AI chips in data centers hit
Serve structured data straight from Blade Continuing with our previous theme on views, let’s get back into Blade. We frequently work with JavaScript and need to utilize the array data that’s sent from our Laravel application to our Blade component. How do you transform that data from a Laravel type array to a JSON file? https://www.dinocajic.com/laravel-p63-optimizing-views/ The first method is something that you’re most likely familiar with: json_encode. While this does work, there is a better way to do it and that’s utilizing the Js::from method. This method ensures that your JSON is properly escaped. If you’re running on a newer version of
Why some tasks feel like sci-fi and others still act like dial-up AI progress isn’t a smooth upward curve; it’s a jagged skyline. One discipline races ahead, another stalls, and a few keep surprising even the optimists. Understanding those gaps is the difference between shipping a game-changing product and burning budget on promises the math can’t keep…yet. Peaks of Superhuman Performance 1. Code & Contracts Large-language models (LLMs) now translate Ruby into Go, refactor legacy COBOL, and draft NDAs in seconds. They live in a world of text-rich, rule-bound data where success is easy to score: does the code compile,
Render faster, shine brighter We’re wrapping up our discussion on views and what better place to finish up on than optimizing our views. https://www.dinocajic.com/laravel-p62-view-composers/ Normally, Blade templates are compiled when requested by the user. Laravel will check to see if a compiled version of the view exists first, and if it does, it will send it, otherwise it will compile it and then send it. If a compiled version exists, Laravel will determine if the uncompiled version has modifications that are dated after the compiled version. If they are, Laravel will recompile the view before sending it. As you can
Why treating every tech role the same stalls growth and invites risk From the outside, “IT” looks tidy: flip the switch, keep the lights on, chase down a mystery error before lunch, go home. Inside that single label, though, lives a sprawling city of specialties, each with its own streets, jargon, and stress levels. Pretend it’s one bucket for long enough and cracks start to show. Meet the Districts System Administrators They patch the servers, test the backups, and chase off the “worked-yesterday” gremlins before anyone else notices a problem. Software Developers Front-end, back-end, DevOps, QA—together they turn ideas into
Wire data into Blade with view composers In the last article we touched on sharing data with multiple views, but we never looked at why we would want to do that. Before we dig through view composers, we really should understand what question they’re trying to answer. https://www.dinocajic.com/laravel-p61-sharing-data-with-all-views/ What is a View Composer? Is a View Composer a Laravel term? No. A view composer is a design pattern used in web development that helps to separate the concerns of generating view data and rendering views in a web application. In a web application, views often require data from multiple sources, such as
