Laravel 7.6 Released

Published on by

Laravel 7.6 Released image

The Laravel team released v7.6.0 yesterday with thirteen new features, along with the latest fixes and changes for the 7.x branch:

Collection “until” Method

Jason McCreary contributed a Collection::until() method that takes items in the collection until a condition is true:

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

This method takes either a closure or a value to compare against the collection.

String Empty Methods

Mark van den Broek contributed a few convenience methods for Stringable and HtmlString. First, HtmlString::isEmpty() makes checking an empty instance more convenient:

$string = new \Illuminate\Support\HtmlString('');
 
// Previously
if (empty($string->toHtml()))
 
// Using isEmpty
if ($string->isEmpty())

Second, Mark contributed an isNotEmpty() convenience method to the Stringable class:

use Illuminate\Support\Stringable;
 
(new Stringable())->isNotEmpty(); // false
(new Stringable('Hello World'))->isNotEmpty(); // true

Stringable Trim Methods

Ryan Chandler contributed ltrim and rtrim methods to the Stringable class to trim characters at the beginning and end of strings:

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'

Ability to Skip Middleware from Route Registration

@dsazup contributed the ability to skip middleware when defining a route:

Route::get('/something')
->skipMiddleware(VerifyCsrfToken::class)
Route::get('/teams/create')
->skipMiddleware(VerifyUserHasTeam::class)

Http Client: Get a JSON Response as an Object

Adrian Nürnberger contributed the object() method to return a 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 Alias Names

Dries Vints contributed setting a component alias name:

I have a use case where I want to conditionally render the contents of a component based on its alias name. For example, when you have an Svg component and use <x:heroicon-o-bell/> which is aliased to the component as follows:

Blade::component(Svg::class, 'heroicon-o-bell');

This is much cleaner than having to do <x:svg name="heroicon-o-bell"/>. Adding the alias name to the Component class will open up many new use cases and possibilities for Blade components…

Append Attributes Across an Eloquent Collection

Niels Faurskov contributed an eloquent collection append() method to append specific attributes across a collection:

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

Retry-After Method Support

@RyanDaDeng contributed method-level support that compliments a queued listener’s retryAfter property for more advanced use-cases:

// listener implementation
 
public function retryAfter()
{
// custom logic for retryAfter
}

Support for the new Composer installed.json Format

Jakub Arbet contributed the ability to support the new snapshot versions of Composer 2 (not yet stable), yet remain backward-compatible with older versions of composer:

The format of vendor/composer/installed.json was changed in the latest snapshot version of composer breaking the package discovery. This PR fixes that with backward compatibility with older versions of composer.

UUID Change Support

Mathieu Tudisco contributed support for using change() with a uuid column, which previously caused the following error:

Unknown column type “uuid” requested.

Release Notes

You can see the full list of new features and updates below and the diff between 7.5.0 and 7.6.0 on GitHub. The full release notes for Laravel 7.x are available in the latest v7 changelog:

v7.6.0

Added

  • Added Collection::until() method (#32262)
  • Added HtmlString::isEmpty() method (#32289, #32300)
  • Added Illuminate\Support\Stringable::isNotEmpty() method (#32293)
  • Added ltrim() and rtrim() methods to Illuminate\Support\Stringable class (#32288)
  • Added ability to skip a middleware (#32347, 412261c)
  • Added Illuminate\Http\Client\Response::object() method (#32341)
  • Set component alias name (#32346)
  • Added Illuminate\Database\Eloquent\Collection::append() method (#32324)
  • Added “between” clauses for BelongsToMany pivot columns (#32364)
  • Support retryAfter() method option on Queued Listeners (#32370)
  • Added support for the new composer installed.json format (#32310)
  • Added uuid change support in migrations (#32316)
  • Allowed store resource into postgresql bytea (#32319)

Fixed

  • Fixed *scan methods for phpredis (#32336)
  • Fixed Illuminate\Auth\Notifications\ResetPassword::toMail() (#32345)
  • Call setLocale in Illuminate\Translation\Translator::__construct() (1c6a504)
  • Used a map to prevent unnecessary array access in Illuminate\Http\Resources\Json\PaginatedResourceResponse::toResponse() (#32296)
  • Prevent timestamp update when pivot is not dirty (#32311)
  • Fixed CURRENT_TIMESTAMP precision bug in Illuminate\Database\Schema\Grammars\MySqlGrammar (#32298)

Changed

  • Added default value to HtmlString constructor (#32290)
  • Used BindingResolutionException to signal problem with container resolution (#32349)
  • Illuminate\Validation\Concerns\ValidatesAttributes.php ::validateUrl() use Symfony/Validator 5.0.7 regex (#32315)

Depreciated

  • Depreciate the elixir function (#32366)
Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Paragraph

Manage your Laravel app as if it was a CMS – edit any text on any page or in any email without touching Blade or language files.

Visit Paragraph
Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $2500/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Lucky Media logo

Lucky Media

Bespoke software solutions built for your business. We ♥ Laravel

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
LaraJobs logo

LaraJobs

The official Laravel job board

LaraJobs
Larafast: Laravel SaaS Starter Kit logo

Larafast: Laravel SaaS Starter Kit

Larafast is a Laravel SaaS Starter Kit with ready-to-go features for Payments, Auth, Admin, Blog, SEO, and beautiful themes. Available with Vue and Livewire stacks.

Larafast: Laravel SaaS Starter Kit
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Rector logo

Rector

Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies

Rector

The latest

View all →
Create a DateTime from a Timestamp With this New Method Coming to PHP 8.4 image

Create a DateTime from a Timestamp With this New Method Coming to PHP 8.4

Read article
Neovim Plugin to for Navigating Laravel and Livewire Components image

Neovim Plugin to for Navigating Laravel and Livewire Components

Read article
Laravel Herd v1.7 is out with updates to the dump UI image

Laravel Herd v1.7 is out with updates to the dump UI

Read article
Share Error Package for Laravel's New Exception Page image

Share Error Package for Laravel's New Exception Page

Read article
Sentry and Laravel announce a new partnership image

Sentry and Laravel announce a new partnership

Read article
"Fast Projects" by Larafast: Real life, ready to use Laravel based Boilerplates image

"Fast Projects" by Larafast: Real life, ready to use Laravel based Boilerplates

Read article