Join the Mastering Laravel community to level up your skills and get trusted advice

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
Curotec

Curotec helps software teams hire the best Laravel developers in Latin America. Click for rates and to learn more about how it works.

Visit Curotec
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
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
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
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
Join the Mastering Laravel community logo

Join the Mastering Laravel community

Connect with experienced developers in a friendly, noise-free environment. Get insights, share ideas, and find support for your coding challenges. Join us today and elevate your Laravel skills!

Join the Mastering Laravel community
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
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

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
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant 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

The latest

View all →
Auto-translate Application Strings with Laratext image

Auto-translate Application Strings with Laratext

Read article
Simplify Factory Associations with Laravel's UseFactory Attribute image

Simplify Factory Associations with Laravel's UseFactory Attribute

Read article
Improved Installation and Frontend Hooks in Laravel Echo 2.1 image

Improved Installation and Frontend Hooks in Laravel Echo 2.1

Read article
Filter Model Attributes with Laravel's New except() Method image

Filter Model Attributes with Laravel's New except() Method

Read article
Arr::from() Method in Laravel 12.14 image

Arr::from() Method in Laravel 12.14

Read article
Streamline API Resources with Laravel's Fluent Methods image

Streamline API Resources with Laravel's Fluent Methods

Read article