Laravel 8.76 Released

Published on by

Laravel 8.76 Released image

The Laravel team released 8.76 with an afterRefreshingDatabase() test method, MySQL invisible modifier support, a new string method, and the latest changes in the v8.x branch.

After Refreshing Database Test Method

Luke Downing contributed an afterRefreshingDatabase method you can use in tests when you want to seed some data in a test directly after running migrations (see the PR description for more details).

Here's an example from the pull request on how to use this method:

abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
use LazilyRefreshDatabase;
 
protected function afterRefreshingDatabase()
{
$this->artisan('db:seed', [
'--class' => RoleAndPermissionSeeder::class
]);
}
}

Customize Child Model Route Binding

@marvin-wtt contributed overriding child model route binding resolution via the resolveRouteBindingQuery method. Check out Pull Request #39929 for further details.

Common 4xx Error Status Code Boolean Checks

Adam Rodriguez contributed a forbidden() and unauthorized method to the Response class. These methods clean up logic around these statuses nicely:

// Before
if ($response->status() === 401) {
// ...
}
 
if ($response->status() === 403) {
// ...
}
 
// After
if ($response->unauthorized()) {
// ...
}
 
if ($response->forbidden()) {
// ...
}

Invisible Modifier for MySQL Columns

Oliver Matla contributed invisible modifier support, introduced in MySQL v8.0.23. When columns are marked as invisible, they are not implicitly (i.e., SELECT *) and thus not hydrated in Laravel models. These columns can still be explicitly selected, making it useful to omit unless you explicitly need the data:

Schema::table('users', function (Blueprint $table) {
$table->string('secret')->nullable()->invisible();
});

This feature is currently only available for MySQL.

String Support for substr_replace()

Ralph J. Smit contributed substrReplace() to Str and Stringable classes:

// Insert a string at a certain position
$string = '1300';
 
$result = Str::substrReplace($string, ':', 2, 0);
// '13:00'
 
// Replace the remainder of a string
$result = (string) Str::of('Laravel Framework')
->substrReplace('– The PHP Framework for Web Artisans', 8);
// 'Laravel – The PHP Framework for Web Artisans'

Release Notes

You can see the complete list of new features and updates below and the diff between 8.75.0 and 8.76.0 on GitHub. The following release notes are directly from the changelog:

v8.76.0

Added

  • Added possibility to customize child model route binding resolution (#39929)
  • Added Illuminate/Http/Client/Response::reason() (#39972)
  • Added an afterRefreshingDatabase test method (#39978)
  • Added unauthorized() and forbidden() to Illuminate/Http/Client/Response (#39979)
  • Publish view-component.stub in stub:publish command (#40007)
  • Added invisible modifier for MySQL columns (#40002)
  • Added Str::substrReplace() and Str::of($string)->substrReplace() methods (#39988)

Fixed

  • Fixed parent call in view (#39909)
  • Fixed request dump and dd methods (#39931)
  • Fixed php 8.1 deprecation in ValidatesAttributes::checkDateTimeOrder (#39937)
  • Fixed withTrashed on routes check if SoftDeletes is used in Model (#39958)
  • Fixes model:prune --pretend command for models with SoftDeletes (#39991)
  • Fixed SoftDeletes force deletion sets "exists" property to false only when deletion succeeded (#39987)
  • Fixed possible out of memory error when deleting values by reference key from cache in Redis driver (#39939)
  • Fixed Password validation failure to allow errors after min rule (#40030)

Changed

  • Fail enum validation with pure enums (#39926)
  • Remove redundant description & localize template (#39928)
  • Fixes reporting deprecations when logger is not ready yet (#39938)
  • Replace escaped dot with place holder in dependent rules parameters (#39935)
  • passthru from property to underlying query object (127334a)
Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Forge
Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $2500/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
LoadForge logo

LoadForge

Easy, affordable load testing and stress tests for websites, APIs and databases.

LoadForge
Paragraph logo

Paragraph

Manage your Laravel app as if it was a CMS – edit any text on any page or in any email without touching Blade or language files.

Paragraph
Lucky Media logo

Lucky Media

Bespoke software solutions built for your business. We ♥ Laravel

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
DocuWriter.ai logo

DocuWriter.ai

Save hours of manually writing Code Documentation, Comments & DocBlocks, Test suites and Refactoring.

DocuWriter.ai
Rector logo

Rector

Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies

Rector

The latest

View all →
Generate Code Coverage in Laravel With PCOV image

Generate Code Coverage in Laravel With PCOV

Read article
Non-backed Enums in Database Queries and a withSchedule() bootstrap method in Laravel 11.1 image

Non-backed Enums in Database Queries and a withSchedule() bootstrap method in Laravel 11.1

Read article
Laravel Pint --bail Flag image

Laravel Pint --bail Flag

Read article
Laravel Herd for Windows is now released! image

Laravel Herd for Windows is now released!

Read article
The Laravel Worldwide Meetup is Today image

The Laravel Worldwide Meetup is Today

Read article
Cache Routes with Cloudflare in Laravel image

Cache Routes with Cloudflare in Laravel

Read article