Laravel 5.4.17 is released
Published on by Eric L. Barnes
Today Laravel released v5.4.17 and it includes several new features including a Collection Times method, improvements to the migrations, and more.
Collection::Times()
Thanks to Joseph Silber the Collection system received a new “Times” method that allows you to do things like this:
$slugs = Collection::times(5, function ($number) {return 'slug-'.$number;}); // ['slug-1', 'slug-2', 'slug-3', 'slug-4', 'slug-5'];
Or inside Model Factories:
$products = Collection::times(5, function ($number) {return factory(Product::class)->create(['name' => 'Product #'.$number]);});
Laravel Migrations
When creating migrations, Laravel wanted you to define both an “up” method and a “down”. This way the system would know what needs to be changed and reset depending on the direction you are going. Now in v5.4.17, migrations will only call the “up” or “down” if the method exists.
Other V5.4.17 Changes include:
- Added getManager() and setManager() to Illuminate\Queue\Worker
- Added ability to set the “timeout” and “persistent” options of a beanstalkd queue connection
- Added Collection::times() method
- Added ability to use flatMap in Collection’s Higher Order messaging
- Add support for multiple — path to migrate:reset
- Store SparkPost Transmission-ID in the header after sending message
- Added ability to customise the no-overlapping strategy used in Scheduled commands
- Only call up() and down() methods on a migration if the method exists
- Fixing caching routes while multiple routes exist with the same path and method
- Preserve route parameter names while resolving the route dependencies
Eric is the creator of Laravel News and has been covering Laravel since 2012.