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.

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
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

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
LaraJobs logo

LaraJobs

The official Laravel job board

LaraJobs
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Rector logo

Rector

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

Rector
MongoDB logo

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB

The latest

View all →
Add Comments to your Laravel Application with the Commenter Package image

Add Comments to your Laravel Application with the Commenter Package

Read article
Laravel Advanced String Package image

Laravel Advanced String Package

Read article
Take the Annual State of Laravel 2024 Survey image

Take the Annual State of Laravel 2024 Survey

Read article
Upload Files Using Filepond in Livewire Components image

Upload Files Using Filepond in Livewire Components

Read article
The Best Laravel Tutorials and Resources for Developers image

The Best Laravel Tutorials and Resources for Developers

Read article
Introducing Built with Laravel image

Introducing Built with Laravel

Read article