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

New Expressive Model Attributes in Laravel 13.2.0

Last updated on by

New Expressive Model Attributes in Laravel 13.2.0 image

Laravel 13.2.0 adds a set of new symmetrical, expressive PHP attributes for Eloquent models, enum support in #[Queue] and #[Connection] attributes, and more.

Key highlights include:

  • New symmetrical Eloquent model attributes (#[DateFormat], #[WithoutTimestamps], and more)
  • Enum support in #[Queue] and #[Connection] queue attributes
  • releaseOnSignal parameter for withoutOverlapping() to handle unexpected process termination
  • UniqueConstraintViolationException now includes column and index information
  • schedule:list displays cron expressions in the correct timezone

What's New

Symmetrical Eloquent Model Attributes

PR #59284 adds a set of focused, single-purpose attributes as alternatives to multi-parameter attributes like #[Table]. Rather than packing multiple concerns into one attribute, each concern now has its own dedicated attribute:

// Before
#[Table(timestamps: false, dateFormat: 'U')]
class Post extends Model {}
 
// After
#[DateFormat('U')]
#[WithoutTimestamps]
class Post extends Model {}

The new attributes mirror properties that already exist on Eloquent models, making it easier to configure model behavior declaratively at the class level.

Pull Request: #59284

Enum Support in #[Queue] and #[Connection]

The #[Queue] and #[Connection] PHP attributes now accept backed enums directly, so you can pass an enum case without calling ->value:

// Before
#[Queue(Queues::LOGS_INGESTION->value)]
final class IngestAuditLog implements ShouldQueue {}
 
// After
#[Queue(Queues::LOGS_INGESTION)]
final class IngestAuditLog implements ShouldQueue {}

This brings the attribute behavior in line with what was already supported through the property directly.

Pull Request: #59278

releaseOnSignal for withoutOverlapping()

withoutOverlapping() now accepts a releaseOnSignal parameter. When true, the overlap lock (stored as a cache key) is released if the process receives a termination signal (SIGTERM, SIGINT, or SIGQUIT), so the task can run again immediately when the scheduler restarts.

Without this, if a scheduler process is killed while a task is running — which can happen on managed infrastructure — the lock is left set and the task won't run again until the overlap TTL expires.

Artisan::command('reports:generate', function () {
// ...
})->withoutOverlapping(releaseOnSignal: true);

Requires the pcntl extension.

Pull Request: #59298

UniqueConstraintViolationException Includes Column and Index Details

UniqueConstraintViolationException now exposes the columns and index name involved in a unique constraint violation. The available data varies by database driver:

Driver columns index
SQLite
PostgreSQL
MySQL
SQL Server
try {
User::create(['email' => 'taken@example.com']);
} catch (UniqueConstraintViolationException $e) {
$e->columns; // e.g. ['email'] on PostgreSQL/SQLite
$e->index; // e.g. 'users_email_unique' on PostgreSQL/MySQL/SQL Server
}

Pull Request: #59299

schedule:list Displays Expressions in the Correct Timezone

The schedule:list command now shows cron expressions adjusted to the timezone configured on each task, rather than always displaying them in the application's default timezone. This makes the output consistent with when the task will actually run.

Pull Request: #59286

Backoff Attribute is Now Variadic

The #[Backoff] attribute now accepts a variadic list of delay values, matching the array-based approach available via the backoff property on queued jobs:

#[Backoff(10, 30, 60)]
class ProcessOrder implements ShouldQueue {}

Pull Request: #59354

Magic Factory Methods Accept Multiple Arrays

The dynamic has*() factory methods (e.g., hasPosts(), hasTags()) now accept multiple arrays, so you can pass different attribute sets for each related model without using forEachSequence() manually:

User::factory()
->hasPosts(['title' => 'First Post'], ['title' => 'Second Post'])
->create();

Under the hood, passing multiple arrays triggers forEachSequence(), creating one related model per array with the given attributes.

Pull Request: #59343

Other Fixes and Improvements

Queue & Workers:

  • Added a TimedOut worker stop reason (#59310)
  • Allow opting out of worker job exception reporting (#59308)
  • Bound the error page query listener to prevent memory bloat in Octane (#59309)

Models & Database:

  • Fixed Table attribute incrementing not working for Pivot models (#59336)
  • Ensured ScopedBy attribute works with inheritance (#59332)
  • Allowed passing enums to model attributes (#59297)
  • Ensured connectUsing() works with UnitEnum (#59306)

Collections:

  • sum() callback now receives the item key as the second argument (#59322)

HTTP & Streaming:

  • Handle exceptions in eventStream() to prevent fatal errors (#59292)
  • Fixed LazyPromise::wait() signature compatibility with Guzzle's PromiseInterface (#59301)

Testing:

  • Fixed missing assertDontSeeInHtml() negation assertion (#59303)

Error Page:

  • Added mobile safe-area-inset support to the exception renderer (#59341)

Performance:

  • Improved raw SQL binding substitution performance (#59277)

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 →
Inertia.js v3.0.0 Is Here with Optimistic Updates, useHttp, and More image

Inertia.js v3.0.0 Is Here with Optimistic Updates, useHttp, and More

Read article
Laravel Boost v2.4.0 Adds Security Audits and a Laravel Best Practices Skill image

Laravel Boost v2.4.0 Adds Security Audits and a Laravel Best Practices Skill

Read article
Building Transaction-Safe Multi-Document Operations in Laravel image

Building Transaction-Safe Multi-Document Operations in Laravel

Read article
Ship AI with Laravel: Building Your First Agent with Laravel 13's AI SDK image

Ship AI with Laravel: Building Your First Agent with Laravel 13's AI SDK

Read article
OG Kit: Generate Dynamic Open Graph Images with HTML and CSS image

OG Kit: Generate Dynamic Open Graph Images with HTML and CSS

Read article
Prism Workers AI — A Cloudflare Workers AI Provider for Prism PHP image

Prism Workers AI — A Cloudflare Workers AI Provider for Prism PHP

Read article