首页 » Web技术 » Laravel » 正文

Laravel 5.3 即将发布 – 新特性抢先看

laravel-5-3

据 Laravel 官方消息,Laravel 5.3 将在今年的 Laracon US 会议期间发布,这就意味着它将在 7 月的 28 号或者 29 号与大家见面。根据列在 Laracon 网站上的时间表,Taylor 将在 Louisville 当地时间 7 月 28 号下午 5:15 演讲,所有应该就会在那个时间。下面,带大家抢先看看 Laravel 5.3 即将带来的新特性。

1. 回滚一个 Migration

Migration 新添加的特性是允许你回滚一个而不是全部:

php artisan migrate:rollback --step=1

2. Blade 模板的 foreach 循环

在 Blade 模板的 @foreach 循环中,你可以使用 $loop 变量。它允许你这么使用:

@if($loop->first)
    Do something on the first iteration.
@endif

@if($loop->last)
    Do something on the last iteration.
@endif

3. Eloquent Collections 会序列化

laravel-collection-serialized

4. 控制台队列输出改为真实的类名称

laravel-queue-console

5. 可以自定义简单的分页

laravel-pagination-customize

6. First or Create

现在 firstOrCreate() 允许传入额外的值:

return User::firstOrCreate(['github_id', $githubUser->id], ['avatar' => $githubUser->avatar]);

7. 查询构造器允许返回集合

查询构造器之前都是返回数组,而现在改为返回集合:

$collection = DB::table('posts')->get();

8. 多个 Migration 路径

现在你可以在 service provider 中加载自定义路径中的 migration:

$this->loadMigrationsFrom('path/to/migrations/folder')

9. Laravel Echo

Laravel Echo 是一个新的特性,相对于现在的广播系统来说是一个很大的提升。

 

via:Laravel News

发表评论