<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/routekey-model-attribute-in-laravel-13-21-6pftxmw3i" -->

---
title: RouteKey Model Attribute in Laravel 13.21 | daily.dev
description: Laravel 13.21 ships several developer-facing additions: a #[RouteKey] PHP attribute for declaratively setting the route model binding column on Eloquent models...
canonical: https://daily.dev/posts/routekey-model-attribute-in-laravel-13-21-6pftxmw3i
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: RouteKey Model Attribute in Laravel 13.21 | daily.dev
og:description: Laravel 13.21 ships several developer-facing additions: a #[RouteKey] PHP attribute for declaratively setting the route model binding column on Eloquent models...
og:url: https://daily.dev/posts/routekey-model-attribute-in-laravel-13-21-6pftxmw3i
og:image: https://api.daily.dev/og/posts/6PFtXMw3i.png
og:image:alt: RouteKey Model Attribute in Laravel 13.21
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# RouteKey Model Attribute in Laravel 13.21

**[Laravel News](https://daily.dev/sources/ln)** · 4 min read · 21 upvotes · 1 comments

## Summary

Laravel 13.21 ships several developer-facing additions: a #[RouteKey] PHP attribute for declaratively setting the route model binding column on Eloquent models (replacing getRouteKeyName() overrides), a base64 validation rule that enforces strict RFC 4648 encoding, a #[RequestAttribute] contextual attribute for injecting request bag values directly into controller parameters, and expanded Image component output formats (PNG, GIF, AVIF, BMP) alongside a fix for the AVIF MIME mapping. The release also introduces a customizable ApplicationBuilder via a protected static property, a standalone illuminate/concurrency subsplit, and a range of bug fixes covering database transaction rollback callbacks, multibyte string handling, enum key support in cache/logging, and pipeline/serve command corrections.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://laravel-news.com/laravel-13-21-0>

## Questions this post answers

### How do I customize the route model binding key in Laravel 13.21 without overriding getRouteKeyName()?

Laravel 13.21 introduces a #[RouteKey] class attribute that lets you declare the binding column directly on the Eloquent model, for example #[RouteKey('slug')] above a Post class. With the attribute present, implicit route model binding resolves the model using that column, and getRouteKeyName() falls back to the primary key only when no attribute is set.

_Track new Eloquent attributes like this as they ship by following Laravel release coverage on daily.dev._

### What does the new base64 validation rule check in Laravel 13.21?

The base64 rule validates that a field is a canonical RFC 4648 Base64 string, added in Laravel 13.21 via $request->validate(['signature' => ['required', 'base64']]). It requires the value to decode in strict mode and re-encode to the exact same string, so padding mistakes or stray characters fail validation, matching a check libraries like Zod already provide.

_Developers hardening request validation can follow rule additions like this through daily.dev._

### How can I inject a value from the request attributes bag into a controller method in Laravel?

Laravel 13.21 adds a #[RequestAttribute] contextual attribute that injects a value straight into a resolved parameter, for example #[RequestAttribute('org')] Organization $org in a controller method. This avoids manually calling $request->attributes->get() and type-hinting the result, which is useful when middleware stashes a tenant or organization object on the request.

_Keep up with Laravel dependency injection features like this via daily.dev for framework upgrades._

## Community discussion

Top comments from developers on daily.dev.

**@sam7work** · 0 upvotes

> actually quite an interesting update, also a bit of a read

## Similar posts on daily.dev

- [New Expressive Model Attributes in Laravel 13.2.0](https://daily.dev/posts/new-expressive-model-attributes-in-laravel-13-2-0-d4iyewmhw) · Laravel News · 24 upvotes · 0 comments
- [UnitTest Attribute and More in Laravel 13.3.0](https://daily.dev/posts/unittest-attribute-and-more-in-laravel-13-3-0-t6ccxev8j) · Laravel News · 15 upvotes · 1 comments
- [Announcing laravel-sluggable v4 with self-healing URLs](https://daily.dev/posts/announcing-laravel-sluggable-v4-with-self-healing-urls-wji92nkx5) · FREEK.DEV · 3 upvotes · 0 comments

---

Tags: [#php](https://daily.dev/tags/php), [#laravel](https://daily.dev/tags/laravel)

[View this post on daily.dev](https://daily.dev/posts/routekey-model-attribute-in-laravel-13-21-6pftxmw3i)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"RouteKey Model Attribute in Laravel 13.21","url":"https://daily.dev/posts/routekey-model-attribute-in-laravel-13-21-6pftxmw3i","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/routekey-model-attribute-in-laravel-13-21-6pftxmw3i"},"datePublished":"2026-07-22T13:45:29.763Z","dateModified":"2026-09-14T09:10:24.123Z","description":"Laravel 13.21 ships several developer-facing additions: a #[RouteKey] PHP attribute for declaratively setting the route model binding column on Eloquent models...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ee40e2048594e45913dd31bd66f36e1c?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ee40e2048594e45913dd31bd66f36e1c?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Laravel News","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Laravel News","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ln","url":"https://daily.dev/sources/ln"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/routekey-model-attribute-in-laravel-13-21-6pftxmw3i","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":21},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"php,laravel","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Laravel News","item":"https://daily.dev/sources/ln"},{"@type":"ListItem","position":3,"name":"RouteKey Model Attribute in Laravel 13.21"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/routekey-model-attribute-in-laravel-13-21-6pftxmw3i","comment":[{"@type":"Comment","text":"actually quite an interesting update, also a bit of a read","datePublished":"2026-07-23T12:23:43.818Z","url":"https://daily.dev/posts/6PFtXMw3i#c-Lque2ELI6","author":{"@type":"Person","name":"Sam","url":"https://daily.dev/sam7work","image":"https://lh3.googleusercontent.com/a/ACg8ocJGz1oRsDNA5jHaL8S_Dm_S69r5oVuMT_253w26IC3wacnjq1U=s96-c"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/routekey-model-attribute-in-laravel-13-21-6pftxmw3i#faq","mainEntity":[{"@type":"Question","name":"How do I customize the route model binding key in Laravel 13.21 without overriding getRouteKeyName()?","acceptedAnswer":{"@type":"Answer","text":"Laravel 13.21 introduces a #[RouteKey] class attribute that lets you declare the binding column directly on the Eloquent model, for example #[RouteKey('slug')] above a Post class. With the attribute present, implicit route model binding resolves the model using that column, and getRouteKeyName() falls back to the primary key only when no attribute is set. Track new Eloquent attributes like this as they ship by following Laravel release coverage on daily.dev."}},{"@type":"Question","name":"What does the new base64 validation rule check in Laravel 13.21?","acceptedAnswer":{"@type":"Answer","text":"The base64 rule validates that a field is a canonical RFC 4648 Base64 string, added in Laravel 13.21 via $request->validate(['signature' => ['required', 'base64']]). It requires the value to decode in strict mode and re-encode to the exact same string, so padding mistakes or stray characters fail validation, matching a check libraries like Zod already provide. Developers hardening request validation can follow rule additions like this through daily.dev."}},{"@type":"Question","name":"How can I inject a value from the request attributes bag into a controller method in Laravel?","acceptedAnswer":{"@type":"Answer","text":"Laravel 13.21 adds a #[RequestAttribute] contextual attribute that injects a value straight into a resolved parameter, for example #[RequestAttribute('org')] Organization $org in a controller method. This avoids manually calling $request->attributes->get() and type-hinting the result, which is useful when middleware stashes a tenant or organization object on the request. Keep up with Laravel dependency injection features like this via daily.dev for framework upgrades."}}]}
```

