Laravel 9.30 Released

The Laravel team released 9.30 with a read-only filesystem option, a scoped filesystem driver, the ability to discard model changes, and more:
Read-only filesystem config option
Frank de Jonge contributed to configuring a filesystem disk to operate in read-only mode. This ensures no write operations are possible on the disk, which is useful when accessing storage you want to ensure doesn't manipulate any files.
Here's a config example from the pull request for this feature:
$disk = $filesystem->build([
'driver' => 'local',
'read-only' => true,
'root' => 'my-custom-path',
'url' => 'my-custom-url',
'visibility' => 'public',
]);
Scoped filesystem driver
Frank de Jonge contributed scoped filesystem drivers, which enables a way to reuse disk configurations. Here's an example from the pull request description:
[
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
's3_videos' => [
'driver' => 'scoped',
'prefix' => 'path/for/videos',
'disk' => 's3',
],
]
Add force option to all "make" commands
James Brooks contributed a --force
flag to all make:*
commands, which is helpful when you need to recreate a file.
"Required if accepted" validation rule
Pascal Baljet contributed a required_if_accepted
validation rule which ensures the field under validation is required if another field is accepted (a value of yes
, on
, 1
, or true
):
Validator::make([
'is_company' => 'on',
'company_name' => 'Apple',
], [
'is_company' => 'required|boolean',
'company_name' => 'required_if_accepted:is_company',
]);
Ability to discard Eloquent model changes
Mior Muhammad Zaki contributed a discardChanges()
method to discard attribute changes and reset attributes to their original state:
$user = new EloquentModelStub([
'name' => 'Taylor Otwell',
]);
$user->getOriginal('name'); // null
$user->getAttribute('name'); // Taylor Otwell
$user->discardChanges();
$user->getAttribute('name'); // null
Determine if attachments exist
Andrew Minion contributed to determining if the given attachments are included in a mailable. Three methods were added that can help assert attachments in tests:
$mailable = new InvoicePaid($user);
// Test normal attachment.
$this->assertTrue(
$mailable->hasAttachment('Receipt.pdf')
);
// Test attachment from storage disk.
$this->assertTrue(
$mailable->hasAttachmentFromStorageDisk('s3', 'invoices', $user->latest_invoice->name)
);
// Test raw attachment.
$this->assertTrue(
$mailable->hasAttachedData('12345', 'confirmation.txt')
);
Release Notes
You can see the complete list of new features and updates below and the diff between 9.29.0 and 9.30.0 on GitHub. The following release notes are directly from the changelog:
v9.30.0 - 2022-09-13
Added
- Added stop_buffering config option to logger (#44071)
- Added read-only filesystem adapter decoration as a config option (#44079)
- Added scoped filesystem driver (#44105)
- Add force option to all make commands (#44100)
Fixed
- Fixed QueryBuilder whereNot with array conditions (#44083)