DEV Community

Morcos Gad
Morcos Gad

Posted on • Edited on

4 3

New Things Added - Laravel 9.14 Released

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

the ability to add table comments for MySQL and Postgres migrations

Schema::table('posts', function (Blueprint $table) {
    $table->comment('This is a comment');
});
Enter fullscreen mode Exit fullscreen mode

Image description

dynamic support of a "trashed" factory state for models using soft deletes

// in Factory class
public function trashed()
{
    return $this->state([
        'deleted_at' => now()->subDay(),
    ]);
}
Enter fullscreen mode Exit fullscreen mode

Image description

new array helper to prepend all key names in an associative array quickly

Arr::prependKeysWith(['key' => 'value'], 'prefix.');

// ['prefix.key' => 'value']
Enter fullscreen mode Exit fullscreen mode
  • Adds ability to have paginate() $perPage parameter as callable with access to $total

https://github.com/laravel/framework/pull/42429

// Previously:
$total = DB::table('products')->count();
DB::table('products')->paginate( $total <= 110 ? 110 : 100 );

// Now (saves extra query and builder code):
DB::table('products')->paginate(function ($total) {
    return $total <= 110 ? 110 : 100;
});
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-14-0
Source :- https://www.youtube.com/watch?v=OC3K69wuCKE

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

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