Home > Article > PHP Framework > Laravel 7.6 is released! ! !
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();
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(''); // Previously if (empty($string->toHtml())) // Using isEmpty if ($string->isEmpty())
Secondly, Mark also contributed the isNotEmpty()
method
use Illuminate\Support\Stringable; (new Stringable())->isNotEmpty(); // false (new Stringable('Hello World'))->isNotEmpty(); // true
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(' Hello World'))->ltrim(); // 'Hello World' echo (new Stringable('Hello World '))->rtrim(); // 'Hello World' echo (new Stringable('/example/'))->rtrim('/'); // '/example'
Ignore middleware for specific routes
@dsazup provides the functionality to skip middleware when defining routes:
Route::get('/something') ->skipMiddleware(VerifyCsrfToken::class) Route::get('/teams/create') ->skipMiddleware(VerifyUserHasTeam::class)
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('some-api.wip')['result']; // Using json() $response = Http::get('some-api.wip')->json(); $response['result'] // New option $response = Http::get('some-api.wip')->object(); $response->result;
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 71184b1345eda804fca2db664de2b690
as an alias for that component, like this:
Blade::component(Svg::class, 'heroicon-o-bell');
This is better than d83b4d8a88cde115fa706f73a95a53ef
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);
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 逻辑 }
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.
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!