Laravel 6.7.0 Released
Published on by Paul Redmond
The Laravel team released a minor version v6.7.0 this week, with the latest features, changes, and fixes for 6.x:
The HasTimestamps
concern has two new methods to return the qualified columns for created and updated timestamp columns:
$model->getQualifiedCreatedAtColumn();// i.e., users.created_at $model->getQualifiedUpdatedAtColumn();// i.e., users.updated_at
A new exceptionContext()
method on the application’s Handler
class provides additional custom logging context:
// App/Exceptions/Handler.phpprotected function exceptionContext(Exception $e){ if ($e instanceof CustomException) { return ['custom_context' => $e->getCustomProperty()]; } return parent::exceptionContext($e);}
The postmark transport will now throw errors instead of failing silently. Nothing needs to change in applications; by updating to the v6.7 release, you’ll get the benefit of exceptions when postmark doesn’t return a 200 status code.
An important withoutRelations()
method is available on models now to allow unloading a model’s relations in a queue job:
Because loaded relationships also get serialized, the serialized job string can become quite large. To prevent relations from being serialized, you can call the withoutRelations method on the model when setting a property value. This method will return an instance of the model with no loaded relationships.
Here’s an example in a queue job constructor, which duplicates the model instance and unloads the relations:
/** * Create a new job instance. * * @param \App\Podcast $podcast * @return void */public function __construct(Podcast $podcast){ $this->podcast = $podcast->withoutRelations();}
Read through the updated queue documentation for more details.
Resource collections can now preserve query parameters on paginated API resources with the preserveQueryParameters()
method:
return MyResourceCollection::make($repository->paginate()) ->preserveQueryParameters();
You can see the full list of new features and updates below and the whole diff between 6.6.2 and 6.7.0 on GitHub. The full release notes for Laravel 6.0 are available in the GitHub v6 changelog:
v6.7.0
Added
- Added
getQualifiedCreatedAtColumn()
andgetQualifiedUpdatedAtColumn()
methods toHasTimestamps
concern (#30792) - Added
exceptionContext()
method to theExceptions\Handler
(#30780) - Added ability for postmark transport to throw errors (#30799, 4320b82)
- Added
withoutRelations()
andunsetRelations()
methods toHasRelationships
(#30802) - Added
ResourceCollection::preserveQueryParameters()
for preserve query parameters on paginated api resources (#30745, e92a708)
Fixed
- Fixed explicit models in string-based database validation rules (#30790)
- Fixed
Routing\RedirectController()
(#30783)