DEV Community

Morcos Gad
Morcos Gad

Posted on

3 3

New Things Added - Laravel 9.7 Released

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

// Previously
$query
    ->whereBelongsTo($category[0])
    ->orWhereBelongsTo($category[1])
    // ...

// Or...
$query->whereIn('category_id', $categories->modelKeys());


// >=9.7 can use collections:
$query->whereBelongsTo($categories);
$query->whereBelongsTo($categories, 'category');
Enter fullscreen mode Exit fullscreen mode

Image description

  • Database Queries Containing Json Paths Support Array Index Braces
DB::table('json_table')
    ->where('column->json_option[0]', 'foo')
    ->update(['column->json_option[0]', => 'bar']);
Enter fullscreen mode Exit fullscreen mode
Route::get('/foo/{bar}')->whereIn('bar', $values);
Enter fullscreen mode Exit fullscreen mode
$this->assertSame(
    'laravel php framework',
    Str::squish(' laravel php framework '));

$this->assertSame(
    'laravel php framework',
    Str::squish("laravel\t\tphp\n\nframework")
);

$this->assertSame(
    'laravel php framework',
    Str::squish('
        laravel
        php
        framework
    ')
);

use Illuminate\Support\Str;
$string = Str::squish('    laravel    framework    ');
// laravel framework
Enter fullscreen mode Exit fullscreen mode
DB::table('users')
    ->whereJsonContainsKey('options->languages')
    ->get();

DB::table('users')
    ->whereJsonDoesntContainKey('options->language->primary')
    ->get();

DB::table('users')
    ->whereJsonContainsKey('options->2fa[0]')
    ->get();

DB::table('users')
    ->whereJsonDoesntContainKey('options->2fa[0][1]')
    ->get();
Enter fullscreen mode Exit fullscreen mode
use App\Jobs\ImportCsv;
use Illuminate\Bus\Batch;
use Illuminate\Support\Facades\Bus;

$batch = Bus::batch([
    (new ImportCsv(1, 100))->delay($delay),
    (new ImportCsv(101, 200))->delay($delay)
])->dispatch();
Enter fullscreen mode Exit fullscreen mode
DB::table('users')->whereNotNull('name')->get();
Enter fullscreen mode Exit fullscreen mode

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-7-0
Source :- https://www.youtube.com/watch?v=tQ2DG-qP6ik

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (2)

Collapse
 
kevincp17 profile image
kevincp17

Nice, thanks for the update Morcos.

Collapse
 
eshimischi profile image
eshimischi

9.8.1 already. Just updated my stack

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