Laravel 9.35 Released


October 12th, 2022

Laravel 9.35 Released

The Laravel team released 9.35 with an exciting new alternate mailable syntax, an Eloquent "strict mode" feature, and more.

Alternate mailable syntax

Taylor Otwell contributed an alternate mailable syntax to works by returning "slim value objects that specify the content and attributes of the mailable"

Here's an example from his pull request description:

namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class InvoicePaid extends Mailable
use Queueable, SerializesModels;
* Create a new message instance.
* @return void
public function __construct()
* Get the message envelope.
* @return \Illuminate\Mail\Mailables\Envelope
public function envelope()
return new Envelope(
subject: 'Invoice Paid',
cc: [new Address('', 'Example Name')],
tags: [],
metadata: [],
* Get the message content definition.
* @return \Illuminate\Mail\Mailables\Content
public function content()
return new Content(
view: 'html-view-name',
text: 'text-view-name',
* Get the attachments for the message.
* @return \Illuminate\Mail\Mailables\Attachment[]
public function attachments()
return [

The traditional way of defining mailables using build() will not be removed. I like how the above example is obvious what is happening using PHP 8's named arguments.

Eloquent "strict" mode

Chris Morrell and Taylor Otwell collaborated on an Eloquent strict mode, which enables the following:

  • No lazy loading
  • Exceptions when assigning non-fillable attributes
  • Exceptions accessing attributes that weren't retrieved or didn't exist

Ideally, you'll use strict mode in development by adding the following to the boot() method of a registered service provider:


The shouldBeStrict() method is a shortcut for enabling all of the following:


Load trashed models with resource routes

Andrew Brown contributed the ability to load trashed models with resource routes using the following routing syntax:

// All endpoints
Route::resource('users', UserController::class)->withTrashed();
// Only `show`
Route::resource('users', UserController::class)->withTrashed(['show']);

Release Notes

You can see the complete list of new features and updates below and the diff between 9.34.0 and 9.35.0 on GitHub. The following release notes are directly from the changelog:



  • Allow loading trashed models for resource routes (#44405)
  • Added Illuminate/Database/Eloquent/Model::shouldBeStrict() and other (#44283)
  • Controller middleware without resolving controller (#44516)
  • Alternative Mailable Syntax (#44462)


  • Fix issue with aggregates (withSum, etc.) for pivot columns on self-referencing many-to-many relations (#44286)
  • Fixes issue using static class properties as blade attributes (#44473)
  • Traversable should have priority over JsonSerializable in EnumerateValues (#44456)
  • Fixed make:cast --inbound so it's a boolean option, not value (#44505)


  • Testing methods. Making error messages with json_encode more readable (#44397)
  • Have 'Model::withoutTimestamps()' return the callback's return value (#44457)
  • only load trashed models on relevant routes (#44478)
  • Adding additional PHP extensions to shouldBlockPhpUpload Function (#44512)
  • Register cutInternals casters for particularly noisy objects (#44514)
  • Use get methods to access application locale (#44521)
  • return only on non empty response from channels (09d53ee, 3944a3e)
  • Correct channel matching (#44531)
  • Migrate mail components (#44527)

Filed in:

Paul Redmond

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