Laravel 8.13 Released


November 10th, 2020

Laravel 8.13 Released

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)

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.