My Blog Posts

Laravel 7.4.0 Released

Laravel 7.4.0 Released


Proxy for Collections

Loris Leiva, Collection::when()the method contributed to the ability to use a higher proxy:

// With this PR, this:
$collection->when($condition, function ($collection) use ($item) {
$collection->push($item);
});
// ... can be refactored as this:
$collection->when($condition)->push($item);

This PR allows you to chain other top proxy methods:

// This:
$collection->when($condition, function ($collection) {
$collection->map->parseIntoSomething();
});
// ... can be refactored as this:
$collection->when($condition)->map->parseIntoSomething();

Artisan expectsChoice() Assertion

Adrian Nuremberger contributed to a command test method to question the choices.

Given the following example:

$name = $this->choice('What is your name?', ['Taylor', 'Dayle'], $defaultIndex);

You can only get the answer to this query; you cannot test the given options.

$this->artisan('question')
-ExpectsQuestion('What is your name?', 'Taylor')
->assertExitCode(0);

With Laravel 7.4, you can:

$this->artisan('question')
-expectsChoice('What is your name?', 'Taylor', ['Taylor', 'Dayle'])
->assertExitCode(0);

You can also change the order of options by querying a fourth boolean argument:

$this->artisan('question')
-expectsChoice('What is your name?', 'Taylor', ['Taylor', 'Dayle'], true)
->assertExitCode(0);

Default Values for @Props Blade Tag

@nihilsen contributed to the ability to identify default supports in the following ways @props:


@props(['type', 'message'])
@php
$type = $type ?? 'info'
@endphp

@props(['type' => 'info', 'message'])

Remove Order from The Query Builder

Jonathan Reinink reorder()orderBy()added a method to the query builder to reset calls:

$query = DB::table('users')-orderBy('name'); $unorderedUsers = $query->reorder()->get();

Reorder allows you to define the default layout in associated tables with the retreat feature as needed:

class Account extends Model
{
public function users()
{
return $this->hasMany(User::class)->orderBy('name');
}
}
// Remove the name orderBy and order by email
$account->users()->reorder()->orderBy('email');
// The same can be written as:
$account->users()->reorder('email');

Release notes

The full list of new features and updates is below and you can see the differences between 7.3.0 and 7.4.0 on GitHub. You can find all version notes for Laravel 7.x in the latest v7 change journal:

v7.4.0

Added

  • make:policycustomizable Brings ( # 32040 , 9d36a36 )
  • HigherOrderWhenProxyApplication for Collections ( # 32148 )
  • Illuminate\Testing\PendingCommand::expectsChoice()# 32139 )
  • Added support for default values for the "props" blade tag ( #32177 )
  • Added Castableinterface ( # 32129 , 9cbf908 , 651371a )
  • Added order removal feature from query builder ( #32186 )

Fixed

  • PendingMailFake:::sendNow()And PendingMailFake::send()# 32093 ) added missing return for
  • Fixing Custom Model Features ( #32118 )
  • Fixed route group ( #32135 , 870efef )

Updated

  • Remove Swift Mailer bonds ( #32165 )
  • Add middleware.stub to files that will be published while running php artisan stub:publish# 32099 )
  • Php artisan stub:publish# 32100 ) add factory.stub to files that will be published when running
  • Add seeder.stub to files to be published while running php artisan stub:publish# 32122 )



Share this article


Comments (0)

Comment