Laravel 9.8 Released


April 13th, 2022

Laravel 9.8 Released

The Laravel team released 9.8 with accessing default form data from an Eloquent model, custom log levels per exception type, discovering anonymous components in additional paths, and more:

The "old" Form Helper Accepts a Model

Andrew Arscott contributed an update to the old() helper that allows a model as the second default argument:

<input type="text" name="name" value="{{ old('name', $user->name) }}">
{{-- 🔥 --}}
<input type="text" name="name" value="{{ old('name', $user) }}">

Allow a Custom Log Level in Exception Handling

Tom Witkowski contributed the ability to customize the log level for reported exceptions in the exception handler:

use PDOException;
use Psr\Log\LogLevel;
* A list of exception types with their corresponding custom log levels.
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
protected $levels = [
PDOException::class => LogLevel::CRITICAL

See Pull Request #41925 for implementation details.

Discover Anonymous Blade Components in Additional Paths

Ralph J. Smit contributed the ability to discover anonymous Blade components in additional paths:

public function boot()
Blade::anonymousComponentNamespace('flights.bookings', 'flights');

Here's an example of anonymous component usage:

<x-flights::panel :flight="$flight" />

Set Factory Method

Ralph J. Smit contributed a model factory set() method to set a single model attribute:

// Before
->create(['name' => 'foo']);
// After
->set('name', 'foo')
// Before
->create(['country' => 'NL']);
// After
->set('country', 'NL')

Release Notes

You can see the complete list of new features and updates below and the diff between 9.7.0 and 9.8.0 on GitHub.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.