Laravel 7.27.0 Released
Published on by Paul Redmond
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)