Let's get started quickly I found new things in Laravel 9.7 Released I wanted to share with you.
- Query Builder whereBelongsTo() Accepts Collections https://github.com/laravel/framework/pull/41733
// 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');
- 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']);
- Route whereIn() Parameter Constraint Method https://github.com/laravel/framework/pull/41794
Route::get('/foo/{bar}')->whereIn('bar', $values);
- String Squish Helper https://github.com/laravel/framework/pull/41791
$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
- Query Builder "whereJsonContainsKey()" Method https://github.com/laravel/framework/pull/41802
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();
- Enable batch jobs delay for database queue https://github.com/laravel/framework/pull/41758
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();
- Add whenNotNull method https://github.com/laravel/framework/pull/41769
DB::table('users')->whereNotNull('name')->get();
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
Top comments (2)
Nice, thanks for the update Morcos.
9.8.1 already. Just updated my stack