Laravel 7.9.0 - Blade Component Improvements

Taylor Otwell
Taylor Otwell

Today I released Laravel 7.9.0. This release includes two improvements for Blade components.

Blade Echo Within Attributes

First, the release fixes a developer experience issue when using Blade components in combination with Laravel Livewire. Previously, specifying a wire:click attribute on a component that utilizes an in-scope PHP variable was very cumbersome since it required binding the attribute as a raw PHP expression:

<x-button :wire:click="'selectPlan(\''.$plan['id'].'\')" />

Beginning in Laravel 7.9.0, you may use the more expected Blade echo syntax:

<x-button wire:click="selectPlan('{{ $plan['id'] }}')">

Parameterless Component Methods

In previous releases of Laravel 7.x, any public component methods that did not require any arguments could be access as variables. For example, imagine a component that has a public countries method to retrieve a list of countries. This method's results could be access like so:

{{ $countries }}

This was unintuitive behavior and inconsistent behavior since developers naturally try to invoke the variable. Beginning in Laravel 7.9.0, public component methods that do not require arguments can be accessed as a variable or by invoking the variable as a callable:

{{ $countries() }}


Taylor Otwell
Taylor Otwell

Latest Stories

Here’s what we've been up to recently.

Request a code sample

Certified Quality. Great Prices

We use cookies to improve your experience and to help us understand how you use our site. By using this site, you accept our use of cookies. Cookie Infox