Laravel 12.50.0 continues the trend of making the framework more type-safe and developer-friendly. While version numbers are moving fast, these changes offer tangible improvements for those looking to clean up their codebase and reduce manual type casting.
Release Overview
- Release Date: February 4, 2026
- Version: 12.50.0
Summary
The 12.50.0 update streamlines common developer tasks by introducing typed getters for the Cache facade and a new withoutAppends() method for Eloquent models. It also enhances collection logic with the hasMany() method and brings the ShouldBeUnique contract to event listeners.
Key Highlights
- Typed Cache Getters: New methods like
Cache::integer()andCache::string()provide built-in type safety. - Unique Queued Listeners: Support for ensuring event listeners only run once if a duplicate is already in the queue.
withoutAppends()for Models: A new method to strip appended attributes from models on demand for better performance.hasMany()Collection Method: Quickly check if a collection contains multiple items that match a specific condition.- URI Parsing: Introduction of the
authority()method for more granular URI support. - Enum Enhancements: Expanded enum support specifically for cache array keys.
- Internal Polish: Numerous bug fixes and significant improvements to internal type hints.
Here is a look at the most impactful changes with code examples to get you started.
Typed Cache Getters
One of the most useful additions is the introduction of typed getters for the Cache facade. Instead of receiving a generic mixed type and manually casting it, you can now ensure your data remains consistent.
// Old way: requires manual casting or docblocks for IDEs
$count = (int) Cache::get('view_count', 0);
// Laravel 12.50.0: Type-safe getters
$count = Cache::integer('view_count', 0);
$name = Cache::string('user_name', 'Guest');
$isActive = Cache::boolean('is_active', false);
$price = Cache::float('product_price', 0.0);
$items = Cache::array('cart_items', []);
Unique Queued Listeners
Previously, ShouldBeUnique was primarily used for Jobs. Now, you can prevent duplicate event listeners from clogging your queue if the previous execution is still processing.
<?php
namespace App\Listeners;
use App\Events\LicenseSaved;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
class AcquireProductKey implements ShouldQueue, ShouldBeUnique
{
public function uniqueId(LicenseSaved $event): string
{
return $event->license->id;
}
public function shouldQueue(LicenseSaved $event): bool
{
return $event->license->product_key === null;
}
public function __invoke(LicenseSaved $event): void
{
// ...
}
}
Eloquent: withoutAppends()
If your models have a large $appends array, they can become slow when converted to JSON or arrays. The new withoutAppends() method allows you to bypass that overhead on the fly.
$user = User::first(); // Contains 'full_name' and 'stats' in $appends
// Returns the model data without running the accessor logic for appends
return $user->withoutAppends()->toArray();
MorphMap Serialization
Laravel now prioritizes your morphMap aliases when serializing models. This prevents broken background jobs if you ever decide to rename a class.
// In your AppServiceProvider
Relation::morphMap([
'post' => 'App\Models\BlogPost',
]);
// When Laravel serializes a 'post' model for a Queue,
// it now records 'post' instead of 'App\Models\BlogPost'.
New Collection Method: hasMany()
Following the addition of hasSole() in the previous version, hasMany() lets you check for the existence of multiple items matching a condition without manually counting.
PHP
$collection = collect([1, 2, 3, 4, 5]);
// Returns true if more than one item is greater than 2
$hasMultiple = $collection->hasMany(fn($value) => $value > 2);
Challenge Your Workflow: Is This "Bloat"?
A skeptic might argue that adding specific methods like Cache::integer() or Collection::hasMany() is "API bloat"—adding more ways to do things we could already do with basic PHP or existing methods.
The Counter-Argument: The goal here isn't just "shorter code," it is intent.
- Using
Cache::integer()tells the next developer (and your IDE) exactly what to expect, reducing bugs caused by unexpectednullorstringreturns. withoutAppends()solves a genuine performance issue where developers were often forced to create separate "DTOs" just to avoid heavy model accessors.
If you find yourself ignoring these new methods, ask yourself: are you writing code that is clear to a human, or just code that "works" for the machine?