Laravel Idea for PhpStorm - Full-featured IDE for productive artisans!

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 Multi-tenant 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
Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate logo

Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate

Build your SaaS application in hours. Out-of-the-box multi-tenancy and seamless Stripe integration. Supports subscriptions and one-time purchases, allowing you to focus on building and creating without repetitive setup tasks.

Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate
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 →
Asymmetric Property Visibility in PHP 8.4 image

Asymmetric Property Visibility in PHP 8.4

Read article
Access Laravel Pulse Data as a JSON API image

Access Laravel Pulse Data as a JSON API

Read article
Laravel Forge adds Statamic Integration image

Laravel Forge adds Statamic Integration

Read article
Transform Data into Type-safe DTOs with this PHP Package image

Transform Data into Type-safe DTOs with this PHP Package

Read article
PHPxWorld - The resurgence of PHP meet-ups with Chris Morrell image

PHPxWorld - The resurgence of PHP meet-ups with Chris Morrell

Read article
Herd Executable Support and Pest 3 Mutation Testing in PhpStorm 2024.3 image

Herd Executable Support and Pest 3 Mutation Testing in PhpStorm 2024.3

Read article