Laravel Cloud is here! Zero-config managed infrastructure for Laravel apps. Deploy now.

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

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
Curotec

Curotec helps software teams hire the best Laravel developers in Latin America. Click for rates and to learn more about how it works.

Visit Curotec
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Bacancy logo

Bacancy

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

Bacancy
Tinkerwell logo

Tinkerwell

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

Tinkerwell
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
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
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
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
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 →
Pest Adds withHost for Browser Testing Subdomains in Laravel image

Pest Adds withHost for Browser Testing Subdomains in Laravel

Read article
Run Artisan Make Commands in Laravel VS Code Extension image

Run Artisan Make Commands in Laravel VS Code Extension

Read article
Livewire 4 Is Dropping Next Week, and wire:transition Makes Animations Effortless image

Livewire 4 Is Dropping Next Week, and wire:transition Makes Animations Effortless

Read article
Laravel 12.45.1, 12.45.2, and 12.46.0 Released image

Laravel 12.45.1, 12.45.2, and 12.46.0 Released

Read article
"Don't Remember" Form Helper Added in Inertia.js 2.3.7 image

"Don't Remember" Form Helper Added in Inertia.js 2.3.7

Read article
Fast Laravel Course Launch image

Fast Laravel Course Launch

Read article