Laravel 5.6.23 and 5.6.24 Released
Published on by Paul Redmond
Two new releases are available for the Laravel framework since we covered Laravel 5.6.22 so let’s see what’s new in the latest versions of Laravel 5.6.
Laravel 5.6.23 Highlights
Laravel v5.6.23—released about 12 days ago—adds the ability to rename database indices, a new event fake, a @canany
directive, and a TestResponse:: assertLocation()
method.
Renaming indices are supported by calling the renameIndex
method with the first argument being the existing index, and the second argument being the new index name:
$table->renameIndex('account', 'account_id') // rename to account_id
In MySQL, Postgres, and MS SQL, renaming indices is a native call. In SQLite, this new change is accomplished by dropping the original index and re-creating a new index.
Next up, a new Event::fakeFor
method allows you to fake events for only a specific part:
Event::fakeFor(function () { return factory(Subscription::class)->create();}, [OnlyThisEvent::class]);
A new @canany
(can any?) directive allows you to check an action conditionally:
@canany(['edit_post', 'delete_post']) {{-- proceed --}}@else {{-- denied --}}@endcanany
The last new feature in Laravel 5.6.23 is a new TestResponse::assertLocation()
assertion:
$response->assertLocation('/orders/1');
Laravel 5.6.24 Highlights
Laravel v5.6.24 shipped on Monday, June 4th with six new features, along with some changes and fixes.
First up is a new test helper method for asserting if the session is error-free:
$this->assertSessionHasNoErrors();
Next up is added support for defining and enforcing a Spatial reference system for a Point column, which I admittedly know nothing about and defer to the PR :)
As of Mysql 8, there is support for spatial reference systems. Currently, there is no way to create a Point column that refers to a specific SRS.
The benefit of having this, is to ensure that when using point datatypes for geocoordinates, they on the correct scale. By default, the column will refer to SRID 0, and when doing calculations ( e.g., the distance between points ) the resulting deviation is huge.
Next, two new query builder methods were added for querying JSON:
$query->whereJsonNotContains('options->languages', ['en']);$query->orWhereJsonNotContains('options->languages', ['en']);
The SerializesModels
and Queueable
traits were added to all notification events. From the PR:
Sometimes the
$notifiable
model in these events have a bunch of extra stuff on it (relationships, etc.) added during a flow and all of this data is being unnecessarily added to queued jobs, from the listeners. This can cause issues for queueing systems because the jobs can have huge payloads.
Route definitions can now use the callable array syntax:
Route::get('smth', [SomeController::class, 'methodName']);
If you prefer the ability to navigate to controller more efficiently in an IDE, this style might suit you.
The last new change in this release is adding JSON SELECT
queries to SQL Server 2016+:
DB::table('users') ->select('items->price') ->where('items->price', 1) ->orderBy('items->price');
Thank you to all the contributors to the latest releases, we see some nice incremental changes in every version!
Here’s the full changelog for both 5.6.23 and 5.6.24:
v5.6.24 (2018-06-04)
Added
- Added assertSessionHasNoErrors() test helper (#24308)
- Added support for defining and enforcing a Spatial reference system for a Point column (#24320)
- Added Builder::whereJsonDoesntContain() and Builder::orWhereJsonDoesntContain() (#24367)
- Added Queueable, SerializesModels to all notification events (#24368)
- Allow callable array syntax in route definition (#24385)
- Added JSON SELECT queries to SQL Server (#24397)
Changed
- Optimize query builder’s
pluck()
method (#23482) - Allow passing object instances regardless of the parameter name to method injection (#24234)
- Extract setting mutated attribute into method (#24307)
- Let apiResource support except option (#24319)
- Skip null/empty values in SeeInOrder (#24395)
- Sync Original modal attributes after soft deletion (#24400)
Fixed
- Fixed typo of missing underscore in
not_regexp
rule name (#24297) - Cleanup null relationships in loadMorph (#24322)
- Fix loadMissing() relationship parsing (#24329)
- Fix FormRequest class authorization validation priority (#24369)
- Fix custom blade conditional ignoring 0 as argument (#24394)
v5.6.23 (2018-05-24)
Added
- Added support for renaming indices (#24147)
- Added
Event::fakeFor()
method (#24230) - Added
@canany
Blade directive (#24137) - Added
TestReponse::assertLocation()
method (#24267)
Changed
- Validation bypass for
before
andafter
rules when paired withdate_format
rule (#24191)