DEV Community

Morcos Gad
Morcos Gad

Posted on • Updated on

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

Top comments (0)