Laravel0Laravel 9.30 Released | Laravel News

[ad_1]

The Laravel team released 9.29 and 9.30 with a read-only filesystem option, a scoped filesystem driver, the ability to discard model changes, and more.

Note: we last covered Laravel 9.28.0, so this release post covers both 9.29 and 9.30.

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:

1$disk = $filesystem->build([

2 'driver' => 'local',

3 'read-only' => true,

4 'root' => 'my-custom-path',

5 'url' => 'my-custom-url',

6 'visibility' => 'public',

7]);

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:

1[

2 's3' => [

3 'driver' => 's3',

4 'key' => env('AWS_ACCESS_KEY_ID'),

5 'secret' => env('AWS_SECRET_ACCESS_KEY'),

6 'region' => env('AWS_DEFAULT_REGION'),

7 'bucket' => env('AWS_BUCKET'),

8 'url' => env('AWS_URL'),

9 'endpoint' => env('AWS_ENDPOINT'),

10 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),

11 'throw' => false,

12 ],

13 's3_videos' => [

14 'driver' => 'scoped',

15 'prefix' => 'path/for/videos',

16 'disk' => 's3',

17 ],

18]

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):

1Validator::make([

2 'is_company' => 'on',

3 'company_name' => 'Apple',

4], [

5 'is_company' => 'required|boolean',

6 'company_name' => 'required_if_accepted:is_company',

7]);

Ability to discard Eloquent model changes

Mior Muhammad Zaki contributed a discardChanges() method to discard attribute changes and reset attributes to their original state:

1$user = new EloquentModelStub([

2 'name' => 'Taylor Otwell',

3]);

4 

5$user->getOriginal('name'); // null

6 

7$user->getAttribute('name'); // Taylor Otwell

8$user->discardChanges();

9$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:

1$mailable = new InvoicePaid($user);

2 

3// Test normal attachment.

4$this->assertTrue(

5 $mailable->hasAttachment('Receipt.pdf')

6);

7 

8// Test attachment from storage disk.

9$this->assertTrue(

10 $mailable->hasAttachmentFromStorageDisk('s3', 'invoices', $user->latest_invoice->name)

11);

12 

13// Test raw attachment.

14$this->assertTrue(

15 $mailable->hasAttachedData('12345', 'confirmation.txt')

16);

Release Notes

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

v9.30.0

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)

Changed

  • Passing event into viaQueue and viaConnection of Queued Listener (#44080)
  • Improve testability of batched jobs (#44075)
  • Allow any kind of whitespace in cron expression (#44110)

v9.29.0

Added

  • Added RequiredIfAccepted validation rule (#44035)
  • Added Illuminate/Foundation/Vite::assetPath() (#44037)
  • Added ability to discard Eloquent Model changes (#43772)
  • Added ability to determine if attachments exist to Illuminate/Mail/Mailable (#43967)
  • Added Illuminate/Support/Testing/Fakes/BusFake::assertNothingBatched() (#44056)

Reverted

Fixed

  • Avoid Passing null to parameter exception on PHP 8.1 (#43951)
  • Align Remember Me Cookie Duration with CookieJar expiration (#44026)
  • Fix Stringable typehints with Enumerable (#44030)
  • Fixed middleware “SetCacheHeaders” with file responses (#44063)

Changed

  • Don’t use locks for queue job popping for PlanetScale’s MySQL-compatible Vitess engine (#44027)
  • Avoid matching ‘use’ in custom Stub templates in Illuminate/Console/GeneratorCommand.php (#44049)

[ad_2]

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *