The team Laravel has released the latest version of Laravel v9.10.0. Laravel 9.10 version includes a findOr() Eloquent method, a new command assertion, retrieving input as a Stringable instance, and much more. Here are some of the new features and updates: Added a findOr method to Eloquent https://github.com/jessarcher introduced a findOr() method to the Eloquent Builder and Relations.
Example usage: User::findOr(1, fn () => throw new RuntimeException); User::findOr(1, fn () => abort(403)); User::findOr(1, fn () => 'return something'); The method also supports passing columns as the second argument: User::findOr(1, ['columns'], fn () => '...'); It also works on HasMany, HasManyThrough, BelongsToMany, MorphMany, and MorphToMany relations: $user->posts()->findOr(1, fn () => '...'); Add doesntExpectOutputToContain assertion method https://github.com/hebinet contributed to this PR that adds the new Command assertion method doesntExpectOutputToContain in Laravel
This function is very useful for the Laravel developers because it allows for running just about anything before the database is refreshed.