Laravel 9.30 - Important Features You Should Know

Biztech

By : Biztech

Laravel 9.30 – Important Features You Should Know1

Laravel has been ranked among the most widely used PHP frameworks for a long time. Known for its attractive syntax, Laravel is an open-source PHP web application framework. Laravel has established itself as one of the standard frameworks for developers and businesses using PHP. It is an MVC framework for creating simple to complex web applications using the PHP programming language. It rigorously follows the MVC (model-view-controller) architectural paradigm. The new Laravel 9.30 release has included a lot of brand-new functionality. You can read about a new release of Laravel if you haven’t used it:

Added
* Laravel 9.30 has added stop_buffering config option to the logger
* Force option to make commands has been added
* As a config option, there is an added feature of read-only filesystem adapter decoration
* Added scoped filesystem driver

Fixed
* Fixed QueryBuilder was not with array conditions

Read-only file system configuration option

This makes sure that no write operation is possible on the disk. This new laravel 9.30 upgrade is useful when accessing storage. You want to ensure it does not manipulate any files. Here’s an example of the read-only file system.

$disk = $filesystem->build([
‘driver’ => ‘local’,
‘read-only’ => true,
‘root’ => ‘my-custom-path’,
‘url’ => ‘my-custom-url’,
‘visibility’ => ‘public’,
]);

‘Required if accepted’ validation rule.

The new version of laravel 9.30 has included ‘Required_if_accepted’ validation rule. It ensures the field under validation is now required if another field is accepted. Here’s an example of it.

Validator::make([
‘is_company’ => ‘on’,
‘company_name’ => ‘Apple’,
], [
‘is_company’ => ‘required|boolean’,
‘company_name’ => ‘required_if_accepted:is_company’,
]);

Scoped file system driver

This enables a way to reuse disk configuration. Here’s an example of it.

[
‘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’,
],
]

Determine if attachments exist

It is to determine if the given attachment included are mailable. Three methods are added in laravel latest version that help asserts in the attachment test.
$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’)
);

Read Also: Laravel 10 Latest Features!

Ability to discard eloquent model changes

In the latest upgrade service ‘discard changes’ method discards attribute the changes and reset the 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

Key features of Laravel

Artisan CLI

Eloquent, Laravel’s object-relational mapper (ORM), is one of the best features as it enables seamless interaction. By using Eloquent, Laravel removes the obstacles related to communicating with and crafting challenging SQL queries to retrieve data from your database. If you have doubts about that, you can easily hire dedicated laravel developers.

Eloquent ORM

Another crucial component of Laravel is the command line interface or Artisan CLI. With it, you don’t need to navigate through folders and files to create or alter any aspect of Laravel from the command line. You don’t even need to install a database client while using Artisan.

Bottom Line

Laravel has become the standard framework for businesses and developers using PHP. The laravel 9.30 release date is Sep 14, 2022. With the new update, Lavarel has moved up its standard by making it easy for developers.

Reference : https://laravel-news.com/laravel-9-30-0

Get a Free Consultation

    ✓ 100% Guaranteed Security of Your Information