Laravel 6.12.0 Released

Laravel 6.12.0 Released

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:

// from a service provider...
$this->loadFactoriesFrom('source/database/factories');

$this->loadFactoriesFrom([
    'source_one/database/factories', 
    'source_two/database/factories',
]);

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:

$response->dumpSession();
$response->dumpSession('example');
$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:

// Returns true
Str::isUuid('a0a2a2d2-0b87-4a18-83f2-2529882be2de');

// Returns false
Str::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:

$request = Request::create('/', 'GET', [
    'example1' => 'true',
    'example2' => 'false',
    'checked' => 1,
    'checked2' => '1',
    'unchecked' => 0,
    'unchecked2' => '0',
    'name' => 'Jane Doe'
]);

$request->boolean('example1'); // true
$request->boolean('example2'); // false
$request->boolean('checked'); // true
$request->boolean('checked2'); // true
$request->boolean('unchecked'); // false
$request->boolean('unchecked2'); // false
$request->boolean('name'); // false

Factory Builder createMany()

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

// Before
factory(User::class)->create([
    'name' => 'Taylor',
]);

factory(User::class)->create([
    'name' => 'John',
]);

// After
factory(User::class)->createMany([
    ['name' => 'Taylor'],
    ['name' => 'John'],
]);

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: News / Releases

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Laravel Partner Seeks Team Lead / Developer
Remote
Kirschbaum Development Group, LLC
Engineering Director
Vancouver or remote (EST/PST preferred)
Engine Digital
Full-Stack Engineer
Vancouver or remote (EST/PST preferred)
Engine Digital
Sr. Software Engineer
Boca Raton - Florida, Remote - USA Only
Honorlock
Lead PHP Developer (€++)
Hoorn, The Netherlands
Portabase