Laravel 7.27.0 Released

News

September 3rd, 2020

Laravel 7.27.0 Released

The Laravel team released 7.27.0 this week with the ability to use aliases of morphed models and new string methods for padding.

As we count down to about a week from the Laravel 8 release, Laravel 7.27 is possibly the last minor release of the 7.x version. Once Laravel 8 is out, v7 will receive essential security updates until March 2021. Refer to the support policy for further details.

Use an Alias of Morphed Model

@thewebartisan7 contributed the ability to use an alias of a morphed model directly:

// Before
$morphable = [
"App\AnotherModel",
Relation::getMorphedModel('alias')
];
$dataset = MyModel::query()
->whereHasMorph('morphable', $morphable)
->with('morphable')
->orderBy('id')
->limit(50)
->get()
->groupBy('morphable_type');
 
// After
$morphable = [
"App\AnotherModel",
'alias',
'another',
"App\YetAnotherModel",
];
$dataset = MyModel::query()
->whereHasMorph('morphable', $morphable)
->with('morphable')
->orderBy('id')
->limit(50)
->get()
->groupBy('morphable_type');

Basic Padding Methods for Strings

Travis Elkins contributed new string methods that wrap PHP’s str_pad() method into Laravel’s Str and Stringable methods. The methods include padBoth(), padLeft(), and padRight():

use Illuminate\Support\Str;
 
// padBoth()
$padded = Str::padBoth('Alien', 10, '_'); // '__Alien___'
$padded = Str::padBoth('Alien', 10); // ' Alien '
 
// padLeft()
$padded = Str::padLeft('Alien', 10, '-='); // '-=-=-Alien'
$padded = Str::padLeft('Alien', 10); // ' Alien'
 
// padRight()
$padded = Str::padRight('Alien', 10, '-'); // 'Alien-----'
$padded = Str::padRight('Alien', 10); // 'Alien '

Release Notes

You can see the full list of new features and updates below and the diff between 7.26.0 and 7.27.0 on GitHub. The following release notes are directly from the changelog:

v7.27.0

Added

  • Allow to use alias of morphed model (#34032)
  • Introduced basic padding (both, left, right) methods to Str and Stringable (#34053)

Refactoring

Changed

  • allow to reset forced scheme and root-url in UrlGenerator (#34039)
  • Updating the make commands to use a custom views path (#34060, b593c62)
  • Using “public static property” in View Component causes an error (#34058)
  • Changed postgres processor (#34055)

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.