Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Laravel 12.45.1, 12.45.2, and 12.46.0 Released

Published on by

Laravel 12.45.1, 12.45.2, and 12.46.0 Released image

Never Miss a Laravel Release 🚀

Sign up and get an email with each new Laravel release

Release Date: January 7, 2026
Laravel Versions: 12.45.1, 12.45.2, 12.46.0

Summary

Laravel released three new framework versions on January 7, 2026, bringing valuable new array and collection helpers, enhanced Gate authorization with enum support, and several important bug fixes. Version 12.46.0 introduces Arr::onlyValues() and Arr::exceptValues() methods for value-based array filtering, plus a new Collection::containsManyItems() method for checking multiple items. Version 12.45.2 adds UnitEnum support to the Gate's has() method, while 12.45.1 fixes a critical issue with ResourceCollections.

Key highlights include:

  • New Arr::onlyValues() and Arr::exceptValues() helper methods for filtering arrays by value
  • Collection::containsManyItems() method for efficient multi-item checks
  • UnitEnum support in Gate's has() method for type-safe authorization
  • Fixes for ResourceCollection array handling and validator rule appending
  • MySQL DDL locking options support
  • Database connection table prefix cloning fix

What's New

New Array Value Filtering Methods

Laravel 12.46.0 introduces two new array helper methods: Arr::onlyValues() and Arr::exceptValues(). These methods complement the existing Arr::only() and Arr::except() helpers by filtering arrays based on their values rather than keys.

The Arr::onlyValues() method filters an array to keep only items whose values match the specified values:

use Illuminate\Support\Arr;
 
$roles = ['admin', 'editor', 'viewer', 'guest'];
 
$allowedRoles = Arr::onlyValues($roles, ['admin', 'editor']);
// Result: [0 => 'admin', 1 => 'editor']

The Arr::exceptValues() method does the opposite, removing items whose values match the specified values:

$statuses = ['pending', 'completed', 'failed', 'shipped'];
 
$activeStatuses = Arr::exceptValues($statuses, ['failed', 'completed']);
// Result: [0 => 'pending', 3 => 'shipped']

Both methods support strict type comparison via an optional third parameter, which is particularly useful when working with mixed-type arrays:

$mixedValues = [1, '1', 2, '2', 3];
 
$integers = Arr::onlyValues($mixedValues, [1, 2, 3], strict: true);
// Result: [0 => 1, 2 => 2, 4 => 3] - only exact type matches

These methods are useful for filtering configuration arrays, removing specific status values, data sanitization based on value allowlists/denylists, and cleaning up form input values.

Pull Request: #58317

Collection Contains Many Items Method

Laravel 12.46.0 adds a new containsManyItems() method to the Collection class. This method determines if a collection contains more than one item, complementing the existing containsOneItem() method.

Basic usage checks if a collection has multiple items:

collect([])->containsManyItems(); // false
collect([1])->containsManyItems(); // false
collect([1, 2])->containsManyItems(); // true
collect([1, 2, 3])->containsManyItems(); // true

The method also accepts an optional callback to check if multiple items match a specific condition:

$users = collect([
['name' => 'John', 'role' => 'admin'],
['name' => 'Jane', 'role' => 'editor'],
['name' => 'Bob', 'role' => 'admin'],
]);
 
// Check if there are multiple admins
$hasMultipleAdmins = $users->containsManyItems(fn($user) => $user['role'] === 'admin');
// Result: true

This method is particularly useful in validation logic to ensure multiple options are selected:

$selectedOptions = collect($request->input('options'));
 
if (! $selectedOptions->containsManyItems()) {
throw ValidationException::withMessages([
'options' => 'Please select at least two options.'
]);
}

The method efficiently returns early once it finds more than one matching item, making it performant even with large collections.

Pull Request: #58312

Gate Authorization with Enum Support

Laravel 12.45.2 enhances the Gate facade's has() method to accept UnitEnum instances, not just strings or BackedEnum types. This allows for more type-safe authorization code when checking if abilities are defined.

Previously, you could only check for ability existence using strings:

if (Gate::has('view-dashboard')) {
// Ability is defined
}

Now you can use PHP enums for type-safe ability checking:

enum Abilities {
case VIEW_DASHBOARD;
case EDIT_POST;
case DELETE_USER;
}
 
Gate::define(Abilities::VIEW_DASHBOARD, fn($user) => $user->isAdmin());
 
if (Gate::has(Abilities::VIEW_DASHBOARD)) {
// Type-safe ability check - works with UnitEnum!
}

This also works seamlessly with BackedEnum types:

enum Permission: string {
case ViewDashboard = 'view-dashboard';
case EditPost = 'edit-post';
}
 
if (Gate::has(Permission::ViewDashboard)) {
// Ability existence check with backed enum
}

This enhancement is particularly useful for dynamically registering permissions and conditional feature registration:

foreach (Permission::cases() as $permission) {
if (! Gate::has($permission)) {
Gate::define($permission, PermissionPolicy::class);
}
}

Pull Request: #58310

Miscellaneous Fixes and Improvements

Laravel 12.45.1, 12.45.2, and 12.46.0 also include several important bug fixes and improvements:

Version 12.46.0:

  • Fixed phpdoc of Container::buildSelfBuildingInstance() to prevent Psalm errors (#58314)
  • Fixed table prefix not being applied when cloning database connections (#58288)
  • Added MySQL DDL locking options to MySQL grammar for better table locking control (#58293)

Version 12.45.2:

  • Fixed Validator::appendRules() when using pipe-separated rule strings (#58304)
  • Fixed calling toArray() on AnonymousResourceCollection to properly return an array of resources (#58302)

Version 12.45.1:

  • Fixed ResourceCollection usage when used with a plain array instead of Model collection (#58299)

Upgrade Notes

These releases are backward compatible and do not require any code changes. Simply update your Laravel framework dependency to the latest version:

composer update laravel/framework

References

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 Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review
Tinkerwell logo

Tinkerwell

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

Tinkerwell
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
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
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

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

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

The latest

View all →
The Laravel Community Mobile App Helps You Discover Events and Connect With Developers image

The Laravel Community Mobile App Helps You Discover Events and Connect With Developers

Read article
A PHP Package for Concurrent Website Crawling image

A PHP Package for Concurrent Website Crawling

Read article
A Clean API for Reading PHP Attributes image

A Clean API for Reading PHP Attributes

Read article
Serve Markdown Versions of Your Laravel Pages to AI Agents image

Serve Markdown Versions of Your Laravel Pages to AI Agents

Read article
The Inertia v3 Beta is Here image

The Inertia v3 Beta is Here

Read article
Polyscope Is an Ai-First Dev Environment for Orchestrating Agents image

Polyscope Is an Ai-First Dev Environment for Orchestrating Agents

Read article