Tinkerwell - The PHP Scratchpad

Laravel 7.6 Released

Published on by

Laravel 7.6 Released image

Never Miss a Laravel Release 🚀

Sign up and get an email with each new Laravel release

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
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review
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 $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Tinkerwell logo

Tinkerwell

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

Tinkerwell
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
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
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

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

Lucky Media
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 →
Bagisto Visual: Theme Framework with Visual Editor for Laravel E-commerce image

Bagisto Visual: Theme Framework with Visual Editor for Laravel E-commerce

Read article
Automate Laravel Herd Worktrees with This Claude Code Skill image

Automate Laravel Herd Worktrees with This Claude Code Skill

Read article
Laravel Boost v2.0 Released with Skills Support image

Laravel Boost v2.0 Released with Skills Support

Read article
Laravel Debugbar v4.0.0 is released image

Laravel Debugbar v4.0.0 is released

Read article
Radiance: Generate Deterministic Mesh Gradient Avatars in PHP image

Radiance: Generate Deterministic Mesh Gradient Avatars in PHP

Read article
Speeding Up Laravel News With Cloudflare image

Speeding Up Laravel News With Cloudflare

Read article