Home > PHP Framework > Laravel > body text

Laravel 7.6 is released! ! !

藏色散人
Release: 2020-04-21 13:11:51
forward
3419 people have browsed it

The Laravel team released v7.6.0 yesterday, which contains 13 new features and the latest fixes and changes for the 7.x branch:

Added "until" method to collections

Jason McCreary contributed the Collection::until() method, which can loop through the collection until the element meets the condition and then return the element:

// Before
[$before, $after] = $primes->partition(function ($item) {
    return $item < 11;
});
$before->dump();
// Using until
$passed = $primes->until(11)->dump();
Copy after login

This method uses a closure Or a value compared to a collection.

String Empty Methods

Mark van den Broek provides some convenience methods for Stringable and HtmlString. The first one, the HtmlString::isEmpty() method makes it easier for us to detect empty instances:

$string = new \Illuminate\Support\HtmlString(&#39;&#39;); 
// Previously
if (empty($string->toHtml()))
// Using isEmpty
if ($string->isEmpty())
Copy after login

Secondly, Mark also contributed the isNotEmpty() method

use Illuminate\Support\Stringable;
(new Stringable())->isNotEmpty(); // false
(new Stringable(&#39;Hello World&#39;))->isNotEmpty(); // true
Copy after login

Trim method of Stringable class

Ryan Chandler contributed the ltrim and rtrim methods to the Stringable class, which can trim the characters at the beginning and end of the string:

use Illuminate\Support\Stringable;
echo (new Stringable(&#39; Hello World&#39;))->ltrim(); // &#39;Hello World&#39;
echo (new Stringable(&#39;Hello World &#39;))->rtrim(); // &#39;Hello World&#39;
echo (new Stringable(&#39;/example/&#39;))->rtrim(&#39;/&#39;); // &#39;/example&#39;
Copy after login

Ignore middleware for specific routes

@dsazup provides the functionality to skip middleware when defining routes:

Route::get(&#39;/something&#39;)
    ->skipMiddleware(VerifyCsrfToken::class)
Route::get(&#39;/teams/create&#39;)
    ->skipMiddleware(VerifyUserHasTeam::class)
Copy after login

Http client: Get JSON response As an object

Adrian Nürnberger contributed the object() method, which returns the JSON response body as an object instead of an associative array:

// Array access
Http::get(&#39;some-api.wip&#39;)[&#39;result&#39;];
// Using json()
$response = Http::get(&#39;some-api.wip&#39;)->json();
$response[&#39;result&#39;]
// New option
$response = Http::get(&#39;some-api.wip&#39;)->object();
$response->result;
Copy after login

Component Aliasing

Contributed by Dries Vints Setting an alias for a component:

I came across a scenario where I needed to conditionally render the contents of a component based on its alias. For example, when you have an Svg component and use <x:heroicon-o-bell /> as an alias for that component, like this:

Blade::component(Svg::class, &#39;heroicon-o-bell&#39;);
Copy after login

This is better than <x:svg name="heroicon-o-bell"/> This way is more concise. Adding aliases to the Component class will add many new uses and possibilities for Blade components...

Append Attributes Across an Eloquent Collection

Niels Faurskov Contributed an eloquent collection method append(), which can append specific attributes to the collection:

// Before Laravel 7.6
$collection->each(function($model) {
    $model->append($attribute)
});
// Append method
$collection->append($attribute);
Copy after login

Supports Retry-After method

@RyanDaDeng contributed a method level Support, he can supplement the retryAfter of the queue listener to apply to more advanced use cases:

// listener implementation
public function retryAfter()
{
    // 自定义 retryAfter 逻辑
}
Copy after login

Support Composer new version installed.json format

Jakub Arbet support Snapshot functionality in new versions of Composer 2 (not yet stable), but still backwards compatible with older versions of composer:

Changed in the latest snapshot version of composervendor/composer/installed.json format, thus destroying the function of automatically discovering packages. This PR addresses this issue through backward compatibility with earlier versions of composer.

UUID supports change

Mathieu Tudisco supports the use of the change() method in the uuid column. Before this, the following error would occur:

Unknown column type “uuid” requested.
Copy after login

Release Notes

You can check out the full list of new features and updates on GitHub below along with 7.5.0 and 7.6.0](https:// github.com/laravel/framework/compare/v7.5.0...v7.6.0). The complete release notes for Laravel 7.x can be found in the latest v7 changelog:

v7.6.0

New

● Added Collection::until() Method (#32262)

● Added HtmlString::isEmpty () Method (#32289, #32300)

● Added Illuminate\Support\Stringable::isNotEmpty() Method (#32293)

Illuminate\Support\Stringable Added new classes ltrim() and rtrim() Method (#32288)

● Added the function of ignoring middleware (#32347, 412261c)

● Added Illuminate\Http\Client\Response::object() method (#32341)

● Support setting component alias (#32346)

● Added Illuminate\Database\Eloquent\Collection::append() method (#32324)

● The pivot column of BelongsToMany adds a new "between" statement (#32364)

● Queue monitoring supports retryAfter() method (#32370 )

● Added format support for composer’s new version of installed.json (#32310)

● Added support for uuid changes in database migration files (#32316)

● Allow saving resources to postgresql bytea (#32319)

Fixed

● Fix the *scan method of phpredis (#32336)

● Fix Illuminate\Auth\Notifications\ResetPassword::toMail() (#32345)

● In Illuminate\Translation\Translator::__construct() call setLocale (1c6a504)

● Use mapping to prevent unnecessary array accessin Illuminate\Http\Resources\Json\PaginatedResourceResponse::toResponse() (#32296)

● When pivot is not Prevent timestamp update when modified (#32311)

● Fix the precision bug of CURRENT_TIMESTAMP in Illuminate\Database\Schema\Grammars\MySqlGrammar (#32298)

Modify

● The constructor of HtmlString increases the default value (#32290)

● Use BindingResolutionException to indicate container resolution problems (#32349)

Illuminate\Validation\Concerns\ValidatesAttributes.php :: validateUrl() Use Symfony/Validator 5.0.7 Match (#32315)

Deprecated

● Deprecated elixir function (#32366)

This article is reprinted:

Original address: https://learnku.com /laravel/t/43480

The above is the detailed content of Laravel 7.6 is released! ! !. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template