DEV Community

Morcos Gad
Morcos Gad

Posted on • Updated on

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

Oldest comments (0)