DEV Community

Morcos Gad
Morcos Gad

Posted on • Edited on

3 3

New Things Added - Laravel 9.10 , 9.11 Released

Let's get started quickly I found new things in Laravel 9.10 , 9.11 Released I wanted to share with you.

  • Before Refreshing Database Function Run code before the database starts refreshing
class DataExportTest extends TestCase
{
    use RefreshDatabase;

    protected $seed = true;

    protected function beforeRefreshingDatabase()
    {
        $this->artisan('db:wipe --database another-database-connection');
    }

    // ...
}
Enter fullscreen mode Exit fullscreen mode
User::findOr(1, fn () => throw new RuntimeException);
User::findOr(1, fn () => abort(403));
User::findOr(1, fn () => 'return something');
User::findOr(1, ['columns'], fn () => '...');

// Also works with relations
$user->posts()->findOr(1, fn () => '...');
Enter fullscreen mode Exit fullscreen mode
$name = $request->string('name');
// or
$name = $request->str('name');
Enter fullscreen mode Exit fullscreen mode
Artisan::command('contains', function () {
    $this->line('My name is Taylor Otwell');
});

$this->artisan('contains')
    ->doesntExpectOutputToContain('Taylor Otwell') // false
Enter fullscreen mode Exit fullscreen mode
$stack = ['Tailwind', 'Alpine', 'Laravel', 'Livewire'];

Arr::join($stack, ', ', ' and ');
// Tailwind, Alpine, Laravel and Livewire

Arr::join($stack, ', ', ', and ');
// Tailwind, Alpine, Laravel, and Livewire
Enter fullscreen mode Exit fullscreen mode
$validatedName = $request->safe()->has('name'); // True
$validatedAge = $request->safe()->has('age'); // False

$validatedName = $request->safe()->missing('name'); // False
$validatedAge = $request->safe()->missing('age'); // True

// Check each key in the array
$validatedName = $request->safe()->has(['name', 'age']);
Enter fullscreen mode Exit fullscreen mode

Image description

Image description

I hope you enjoyed with me and to learn more about this release visit the sources and search more. I adore you who search for everything new.
Source :- https://laravel-news.com/laravel-9-10-0
Source :- https://www.youtube.com/watch?v=vO-uRGPtlP0
Source :- https://laravel-news.com/laravel-9-11-0
Source :- https://www.youtube.com/watch?v=uViQgxDZi1M

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Cloudinary image

Video API: manage, encode, and optimize for any device, channel or network condition. Deliver branded video experiences in minutes and get deep engagement insights.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay