Laravel 8.13 Released

Published on by

Laravel 8.13 Released image

The Laravel team released 8.13 this week and updated the changelog detailing all the new features in last week’s 8.12 release. The new features added to Laravel over the previous few weeks are packed with exciting framework updates, so let’s look at what’s new!

8.12: Create Observers With a Custom Path

@StefanoDucciConvenia contributed the ability to use stubs with the make:observer command (#34911).

8.12: Lazy Method in 8.x Eloquent Factory

Mathieu TUDISCO contributed the ability to create a callback that persists a model in the database when invoked. In previous versions of Laravel, the FactoryBuilder had a lazy() method that only creates a record if called. Now, 8.x factories can do the same:

$factory = User::factory()->lazy();
$factory = User::factory()->lazy(['name' => 'Example User']);

8.12: Encrypted String Eloquent Cast

Jason McCreary contributed an eloquent cast that will handle encryption and decryption of a simple string:

public $casts = [
'access_token' => 'encrypted',

8.12: New DatabaseRefreshed Event

Adam Campbell contributed a new DatabaseRefreshed event that fires right after both a migrate:fresh and migrate:refresh command. The new event allows developers to perform secondary actions after refreshing the database. You may use the event class from the following namespace:


8.12: New withColumn() to support Aggregate Functions

Khalil Laleh contributed a withColumn method to support more SQL aggregation functions like min, max, sum, avg, etc. over relationships:

Post::withMax('comments', 'created_at');
Post::withMin('comments', 'created_at');
Post::withSum('comments', 'foo');
Post::withAvg('comments', 'foo');

You might want to check out Pull Request #34965 for more details.

8.12: Add explain() to Eloquent/Query Builder

Illia Sakovich contributed an explain() method to the query builder/eloquent builder, which allows you to receive the explanation query from the builder:

Webhook::where('event', 'users.registered')->explain()
Webhook::where('event', 'users.registered')->explain()->dd()

Now you can call explain() to return the explanation or chain a dd() call to die and dump the explanation.

8.12: Full PHP 8 Support

Dries Vints has been working on adding PHP 8 support to the Laravel ecosystem, which involves various libraries (both first- and third-party libraries) and coordination of many efforts. A HUGE thanks to Dries and all those involved in getting Laravel ready for the next major PHP version!

8.12: Route Registration Methods

Gregori Piñeres contributed some route regex registration methods to easily define route params for repetitive, regular expressions you might add to route params:

// Before. This is still a valid, acceptable way of defining routes
'author' => '[0-9]+',
'book' => '[a-zA-Z]+'
// New optional syntax
// New methods support multiple args
->whereAlpha('author', 'book');

8.12: Don’t Release Option for Job Rate Limiting

Paras Malhotra contributed a dontRelease() option for RateLimited and RateLimitedWithRedis job middleware:

public function middleware()
return [(new RateLimited('backups'))->dontRelease()];

When called, the dontRelease() method will not release the job back to the queue when the job is rate limited.

8.13: Aggregate Load Methods

In 8.12, Khalil Laleh contributed the withColumn() method to support aggregate functions. In 8.13, he contributed load* methods for aggregate functions:

public function loadAggregate($relations, $column, $function = null)
public function loadCount($relations)
public function loadMax($relations, $column)
public function loadMin($relations, $column)
public function loadSum($relations, $column)
public function loadAvg($relations, $column)

8.13: Add chunk() to Fluent Strings

Chris Kankiewicz contributed a chunk() method to fluent strings which allows a string to be chunked by a specific length:

// returns a collection
// Returns 'foo-bar-baz'

Release Notes

You can see the full list of new features and updates below and the diff between 8.11.0 and 8.12.0 and 8.12.0 and 8.13.0 on GitHub. The following release notes are directly from the changelog: *



  • Added loadMax() | loadMin() | loadSum() | loadAvg() methods to Illuminate\Database\Eloquent\Collection. Added loadMax() | loadMin() | loadSum() | loadAvg() | loadMorphMax() | loadMorphMin() | loadMorphSum() | loadMorphAvg() methods to Illuminate\Database\Eloquent\Model (#35029)
  • Modify Illuminate\Database\Eloquent\Concerns\QueriesRelationships::has() method to support MorphTo relations (#35050)
  • Added Illuminate\Support\Stringable::chunk() (#35038)


  • Fixed a few issues in Illuminate\Database\Eloquent\Concerns\QueriesRelationships::withAggregate() (#35061, #35063)


  • Set chain queue | connection | delay only when explicitly configured in (#35047)


  • Remove redundant unreachable return statements in some places (#35053)



  • Added ability to create observers with custom path via make:observer command (#34911)
  • Added Illuminate\Database\Eloquent\Factories\Factory::lazy() (#34923)
  • Added ability to make cast with custom stub file via make:cast command (#34930)
  • ADDED: Custom casts can implement increment/decrement logic (#34964)
  • Added encrypted Eloquent cast (#34937, #34948)
  • Added DatabaseRefreshed event to be emitted after database refreshed (#34952, f31bfe2)
  • Added withMax()|withMin()|withSum()|withAvg() methods to Illuminate/Database/Eloquent/Concerns/QueriesRelationships (#34965, f4e4d95, #35004)
  • Added explain() to Query\Builder and Eloquent\Builder (#34969)
  • Make multiple_of validation rule handle non-integer values (#34971)
  • Added setKeysForSelectQuery method and use it when refreshing model data in Models (#34974)
  • Full PHP 8.0 Support (#33388)
  • Added Illuminate\Support\Reflector::isCallable() (#34994, 8c16891, 31917ab, 11cfa4d, #34999)
  • Added route regex registration methods (#34997, 3d405cc, c2df0d5)
  • Added dontRelease option to RateLimited and RateLimitedWithRedis job middleware (#35010)


  • Fixed check of file path in Illuminate\Database\Schema\PostgresSchemaState::load() (268237f)
  • Fixed: PhpRedis (v5.3.2) cluster – set default connection context to null (#34935)
  • Fixed Eloquent Model loadMorph and loadMorphCount methods (#34972)
  • Fixed ambigious column on many to many with select load (5007986)
  • Fixed Postgres Dump (#35018)


  • Changed make:factory command (#34947, 4f38176)
  • Make assertSee, assertSeeText, assertDontSee and assertDontSeeText accept an array (#34982, 2b98bcc)
Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.


Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Manage your Laravel app as if it was a CMS – edit any text on any page or in any email without touching Blade or language files.

Visit Paragraph
Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo


The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Kirschbaum logo


Providing innovation and stability to ensure your web application succeeds.

Shift logo


Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Bacancy logo


Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $2500/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

LoadForge logo


Easy, affordable load testing and stress tests for websites, APIs and databases.

Paragraph logo


Manage your Laravel app as if it was a CMS – edit any text on any page or in any email without touching Blade or language files.

Lucky Media logo

Lucky Media

Bespoke software solutions built for your business. We ♥ Laravel

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce logo

Save hours of manually writing Code Documentation, Comments & DocBlocks, Test suites and Refactoring.
LaraJobs logo


The official Laravel job board

All Green logo

All Green

All Green is a SaaS test runner that can execute your whole Laravel test suite in mere seconds so that you don't get blocked – you get feedback almost instantly and you can deploy to production very quickly.

All Green
Larafast: Laravel SaaS Starter Kit logo

Larafast: Laravel SaaS Starter Kit

Larafast is a Laravel SaaS Starter Kit with ready-to-go features for Payments, Auth, Admin, Blog, SEO, and beautiful themes. Available with VILT and TALL stacks.

Larafast: Laravel SaaS Starter Kit
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a 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
Rector logo


Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies


The latest

View all →
Automatic Blade Formatting on Save in PhpStorm image

Automatic Blade Formatting on Save in PhpStorm

Read article
PhpStorm 2024.1 Is Released With a Integrated Terminal, Local AI Code Completion, and More image

PhpStorm 2024.1 Is Released With a Integrated Terminal, Local AI Code Completion, and More

Read article
Laravel Prompts Adds a Multi-line Textarea Input, Laravel 11.3 Released image

Laravel Prompts Adds a Multi-line Textarea Input, Laravel 11.3 Released

Read article
Bartender Is an Opinionated Way to Authenticate Users Using Laravel Socialite image

Bartender Is an Opinionated Way to Authenticate Users Using Laravel Socialite

Read article
Jeffrey Way's PhpStorm Setup in 2024 image

Jeffrey Way's PhpStorm Setup in 2024

Read article
Easily Optimize PDFs in Laravel with the Optimizer Package image

Easily Optimize PDFs in Laravel with the Optimizer Package

Read article