What are Laravel 5.2's new features?
[UPDATE] Laravel 5.2 is now available. Check out its features here:
http://learninglaravel.net/laravel-52-is-released
Laravel 5.2 is coming soon. Let's take a look at its new features to know what we will be getting:
Middleware Groups
Middleware groups is a really good feature that you may want. You can now apply group of middlware to routes
MySQL JSON Column Types
Laravel 5.2 now adds support native JSON data type
Form Array Validation
Now you can add validation rules to loop through arrays automatically and validate those arrays for you.
Form input:
<p>
<input type="text" name="post[1][id]">
<input type="text" name="post[1][title]">
</p>
<p>
<input type="text" name="post[2][id]">
<input type="text" name="post[2][title]">
</p>
Validation rules:
Validator::make($request->all(), [
'post.*.id' => 'exists:posts.id',
'post.*.title' => 'required:string',
]);
Database Session Driver
The database session driver now includes user_id and ip_address.
Collections Wildcards
You can use * as a wildcard to get data from a collection
$posts->pluck(‘users.*.name’);
Auth Scaffolding
Want a set of view files for authentication, registration, and password resets? You can easily generate those using:
php artisan make:auth
Implicit model binding
Now you can tell Laravel to automatically binds a model to a route:
Route::get('/posts/{post}', function(Post $post) {
return $post;
});
Laravel will run Post::findOrFail($post) and inject the result into the $post variable automatically! Cool!
Authentication Drivers / "Multi-Auth"
In Laravel 5.2, you may define additional authentication drivers as well define multiple authenticatable models or user tables. For example, if your app has multiple tables, you may now use the Auth methods to authenticate against each of these tables separately.
Eloquent Global Scope Improvements
In Laravel 5.2, global query scopes only require you to implement a single, simple method: apply.
Conclusion
There are many new features! More features are coming! Laravel 5.2 will be released soon. Be sure to join our newsletter to get latest news and freebies.
This post is submitted by our members. Submit a new post.
Tags: Tutorials Laravel 5 Laravel 5.1 News