Friday, March 24, 2023
HomePHPLaravel 9.51 Launched|Laravel Information

Laravel 9.51 Launched|Laravel Information


The Laravel group launched 9.51 today with a brand-new data source question matter assumption, partnership contractor for one/many with, HTTP URI design templates, as well as extra.

Prior to we reach the primary Laravel structure launch, today additionally saw some amazing brand-new attributes throughout the Laravel environment. The truth that all this is delivering a week prior to Laravel 10 still strikes my mind!

Laravel Sail include command

Tony Messias added a sail: include command that you can make use of to include brand-new solutions to an existing Sail setup.

Laravel Sunset data source truncation

Patrick O’Meara added a DatabaseTruncation characteristic that will certainly move your data source and after that trim your tables to quicken rerunning data source movements. See the Sunset Making Use Of Data Source Truncations documents for additional information.

Currently, onto what’s brand-new in Laravel 9.51:

Data source question matter examination assumption

Tim MacDonald added an examination assumption for data source question matter. This assumption can make certain code does not unintentionally present brand-new data source questions:

public feature testItWorksEfficiently()

{

$ this->> expectsDatabaseQueryCount( 5);

// do things ...

// tosses an exemption on tearDown if greater than 5 questions have actually run

// because the assumption was developed.

}

Pending “has several with” as well as “has one with” contractor

Tim MacDonald added a pending contractor for has-one-through as well as has-many-through connections. The instance given up Pull Demand # 45894 has the adhering to connections:

  • Job -> > Has Several -> > Setting
  • Setting -> > Has Several -> > Implementation

Provided the above connections, below’s just how you can compose a “has several with” partnership with the pending contractor:

course Job expands Design

{

public feature releases()

{

return $ this->> with($ this->> settings())

->> has( fn ( Setting $env) => > $env->> releases());

}

public feature settings()

{

return $ this->> hasMany( Setting:: course);

}

}

To highlight the “has one with” partnership, take the adhering to existing connections:

  • Auto Mechanic -> > Has One -> > Vehicle
  • Vehicle -> > Has One -> > Proprietor

Provided the above connections, below’s just how you can compose the “has one with” partnership with the pending contractor:

course Auto Mechanic expands Design

{

public feature proprietor()

{

return $ this->> with($ this->> vehicle())

->> has( fn ( Vehicle $vehicle) => > $vehicle->> proprietor());

}

public feature vehicle()

{

return $ this->> hasOne( Vehicle:: course);

}

}

See the Has Numerous With as well as the Has One With documents for additional information on connections with Laravel.

HTTP customer URI design templates

James Brooks added URI design templates to the Laravel HTTP customer, which utilizes guzzlehttp/uri-templates under the hood:

Http:: withUrlParameters([

'endpoint' => 'https://laravel.com',

'page' => 'docs',

'version' => '9.x',

'thing' => 'validation',

])->> obtain(' {+endpoint}/ {web page}/ {variation}/ {point} ');

// https://laravel.com/docs/9.x/validation

Launch Notes

You can see the total listing of brand-new attributes as well as updates listed below as well as the diff in between 9.50.0 as well as 9.51.0 on GitHub. The adhering to launch notes are straight from the changelog:

v9.51.0

Included

  • Included Illuminate/Foundation/Testing/ Concerns/InteractsWithDatabase:: expectsDatabaseQueryCount() ( # 45932)
  • Included pending has-many-through as well as has-one-through contractor ( # 45894)
  • Included Illuminate/Http/Client/ PendingRequest:: withUrlParameters() ( # 45982)

Taken Care Of

  • Repair: protect against copied content-type on HTTP customer ( # 45960)
  • Include missing out on php expansions in author ( # 45941)

Altered

  • Command routine: job small attributes: routine: run outcome documents & & setting particular redundancy ( # 45949)
  • Included missing out on self scheduled word to reservedNames selection in Illuminate/Console/GeneratorCommand. php ( # 46001)
  • pass worth along to ttl callback in Illuminate/Cache/Repository:: keep in mind() ( # 46006)
  • Make certain the lock_connection is utilized for routine’s withoutOverlapping() ( # 45963)



RELATED ARTICLES

Most Popular

Recent Comments