Laravel 6.12.0 Released

News

January 23rd, 2020

laravel6.jpg

The Laravel team released v6.12.0 this week with the ability to load factories from a package, dump test session data, and many other features! This release is jam-packed with contributions that add some sweet syntactic sugar for repetitive things like filtering a request input as a Boolean.

Here’s a look at some of the highlight new features:

Load Factories from a Package

Gergo D. Nagy contributed a pull request to load factory files in a service provider. Packages can benefit from using existing factories from a package instead of recreating them:

1// from a service provider...
2$this->loadFactoriesFrom('source/database/factories');
3
4$this->loadFactoriesFrom([
5 'source_one/database/factories',
6 'source_two/database/factories',
7]);

Dump Session in a Test Response

Andrew Brown contributed a dumpSession() method to the TestResponse class that provides convenience around dumping the whole session or specific keys:

1$response->dumpSession();
2$response->dumpSession('example');
3$response->dumpSession(['example', 'example2']);

Str::isUuid() Helper

@leonhh contributed a isUuid() string helper by extracting the logic from the ValidatesAttributes trait used the validate UUIDs:

1// Returns true
2Str::isUuid('a0a2a2d2-0b87-4a18-83f2-2529882be2de');
3
4// Returns false
5Str::isUuid('laravel');

Request Boolean Method

Lasse Rafn contributed a Request::boolean() method which takes input and filters it through filter_var to determine if the value is boolean. Here are some examples:

1$request = Request::create('/', 'GET', [
2 'example1' => 'true',
3 'example2' => 'false',
4 'checked' => 1,
5 'checked2' => '1',
6 'unchecked' => 0,
7 'unchecked2' => '0',
8 'name' => 'Jane Doe'
9]);
10
11$request->boolean('example1'); // true
12$request->boolean('example2'); // false
13$request->boolean('checked'); // true
14$request->boolean('checked2'); // true
15$request->boolean('unchecked'); // false
16$request->boolean('unchecked2'); // false
17$request->boolean('name'); // false

Factory Builder createMany()

Mohamed Benhida contributed the factory createMany() method, which aids in creating multiple records with custom data:

1// Before
2factory(User::class)->create([
3 'name' => 'Taylor',
4]);
5
6factory(User::class)->create([
7 'name' => 'John',
8]);
9
10// After
11factory(User::class)->createMany([
12 ['name' => 'Taylor'],
13 ['name' => 'John'],
14]);

You can see the full list of new features and updates below and the whole diff between 6.11.0 and 6.12.0 on GitHub. The full release notes for Laravel 6.0 are available in the GitHub v6 changelog:

v6.12.0 (2020-01-21)

Added

  • Added ServiceProvider::loadFactoriesFrom() method (#31133)
  • Added TestResponse::dumpSession() method (#31131)
  • Added Str::isUuid() method (#31148)
  • Restored phpunit 7 support (#31113)
  • Added Request::boolean() method (#31160)
  • Added Database\Eloquent\FactoryBuilder::createMany() (#31171, 6553d59)
  • Added missing options for PhpRedis (#31182)

Fixed

  • Fixed Cache\RedisLock::acquire() (#31168, 8683a3d)
  • Fixed database url parsing for connections with no database specified (#31185)
  • Prevent ambiguous column with table name prefix (#31174)

Optimization

  • Fixed memory usage on downloading large files (#31163)

Changed

  • Replace Event Dispatcher in resolved cache repositories when Event::fake() is used (#31119, 0a70beb)

Filed in:

Paul Redmond

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