Two days ago Taylor Otwell released a new minor version of Laravel framework – 5.2.22. Along with some small fixes, there are a few new functions, let’s look into them.

A lot of people think that Laravel is a creature by Taylor Otwell only, but in fact there are more people contributing to the framework now – one of them is Mohamed Said from Egypt, who shared the news about new features in 5.2.22, so here we go:

  1. Validate array distinct

New rule to validate if array has only different values:

  ['products.*.product_id' => 'distinct']
);

Validator::make(
  ['products' => 
    ['product_id' => 1, 'quantity' => 5],
    ['product_id' => 1, 'quantity' => 99],
    ['product_id' => 2, 'quantity' => 1],
  ],
  ['products.*.product_id' => 'distinct']
);

This validation will fail, cause there are multiple products with same product_id value.

  1. fullUrlWithQuery()

If you ever need to form a URL with adding some GET parameters to the end, now you can take a current request and append an array to it. Here’s an example – let’s say your current URL is domain.com/catalog and you want new URL to be domain.com/catalog?category=1&order=price:

$request->fullUrlWithQuery(['category' => '1', 'order' => 'price']);