Try Depot: Bring ultra-fast, remote Docker builds directly to your Laravel workflow

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
Bacancy

Outsource a dedicated Laravel developer for $3,200/month. With over a decade of experience in Laravel development, we deliver fast, high-quality, and cost-effective solutions at affordable rates.

Visit Bacancy
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
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
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 →
Laravel Adds an Official Svelte + Inertia Starter Kit image

Laravel Adds an Official Svelte + Inertia Starter Kit

Read article
MongoDB Vector Search in Laravel: Finding the Unqueryable image

MongoDB Vector Search in Laravel: Finding the Unqueryable

Read article
Laravel Cloud Adds “Markdown for Agents” to Serve AI-Friendly Content image

Laravel Cloud Adds “Markdown for Agents” to Serve AI-Friendly Content

Read article
Laravel Releases Nightwatch MCP Server for Claude Code and AI Agents image

Laravel Releases Nightwatch MCP Server for Claude Code and AI Agents

Read article
Single Table Inheritance for Eloquent Models Using Parental image

Single Table Inheritance for Eloquent Models Using Parental

Read article
Laravel Live Denmark Returns to Copenhagen in August 2026 image

Laravel Live Denmark Returns to Copenhagen in August 2026

Read article