Thứ Năm, 20 tháng 10, 2016

Laravel 5 tutorial : Laravel v5.3.19 is now released [HOT]


Laravel 5 tutorial - Laravel released v5.3.19 which includes a few small changes and improvements as well as a complete rewrite of the middleware sorting so that middleware calls with parameters now work properly.

Laravel 5.3.19 make:model

A new addition to Laravel is the ability to specify the creation of a resourceful controller when you are creating a new Model through Artisan, see how to make model in laravel 5.3. This means you can pass a -c or --controller flag to make:model :

php artisan make:model Post --controller

Laravel Image Dimensions Validation

New in Laravel v5.3 is the ability to validate image files to ensure they meet certain dimensions and through the validator this can be setup with a string format:

'avatar' => 'dimensions:min_width=100,min_height=200,ratio=3/2'

Now in v5.3.19 this can be specified through a fluent syntax similar to unique and exists validation rules:

Rule::dimensions()->minWidth(100)->minHeight(100)->ratio(3/2)

laravel 5 release date

Laravel Validation in and not_in

Read how to use Validation in laravel 5.3. The in and not_in validation received the ability to pass an array.

// Previous
in:php,laravel,...
// New
Rule::in(['php','laravel'])

Then the same for not_in

// Previous
not_in:php,laravel,...
// New
Rule::notIn(['php', 'laravel'])

Either style is valid and the new object-based style parses down into the old way. So you are free to use whichever suits your app.

After Validation Hook

Now your controllers can have a new withValidator method so you can easily call any hooks after validation:

protected function withValidator($validator) 
{
  $validator->after(function($validator) {
    if ($this->somethingElseIsInvalid()) {
        $validator->errors()->add('field', 'Something is wrong with this field!');
    }
  });
}

Previously you had to manually setup the $validator = Validator::make() before you could use an after hook which meant you lost the ability to utilize the ValidatesRequests trait.

Upgrading Laravel

To get this latest version all you need to do is run composer update and you can find a complete list of changes in the changelog.

References : https://laravel-news.com/2016/10/laravel-v5-3-19/?utm_medium=feed&utm_source=twitter.com&utm_campaign=Feed%3A+laravelnews

Laravel 5.3 Video's Tutorial



See you next Lessons ...

Không có nhận xét nào:

Đăng nhận xét