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()andArr::exceptValues()helper methods for filtering arrays by value Collection::containsManyItems()method for efficient multi-item checksUnitEnumsupport in Gate'shas()method for type-safe authorization- Fixes for
ResourceCollectionarray 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(); // falsecollect([1])->containsManyItems(); // falsecollect([1, 2])->containsManyItems(); // truecollect([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()onAnonymousResourceCollectionto properly return an array of resources (#58302)
Version 12.45.1:
- Fixed
ResourceCollectionusage 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
- Official Changelog v12.46.0: https://github.com/laravel/framework/blob/12.x/CHANGELOG.md#v12460
- Official Changelog v12.45.2: https://github.com/laravel/framework/blob/12.x/CHANGELOG.md#v12452
- Official Changelog v12.45.1: https://github.com/laravel/framework/blob/12.x/CHANGELOG.md#v12451
- PR: Pull Request #58317 - https://github.com/laravel/framework/pull/58317
- PR: Pull Request #58312 - https://github.com/laravel/framework/pull/58312
- PR: Pull Request #58310 - https://github.com/laravel/framework/pull/58310
- PR: Pull Request #58314 - https://github.com/laravel/framework/pull/58314
- PR: Pull Request #58304 - https://github.com/laravel/framework/pull/58304
- PR: Pull Request #58302 - https://github.com/laravel/framework/pull/58302
- PR: Pull Request #58299 - https://github.com/laravel/framework/pull/58299
- PR: Pull Request #58293 - https://github.com/laravel/framework/pull/58293
- PR: Pull Request #58288 - https://github.com/laravel/framework/pull/58288