Most recently, the release of the minor version 5.2.22 of our favorite Laravel framework has taken place. Along with some minor fixes, there are some new features, let's look at them.
1. Check the uniqueness of the array
The new rule to check if the array has only unique values:
')
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 not work because there are several products with the same value for product_id.
2. fullUrlWithQuery ()
Many, probably, had to form a URL based on the current one, with the addition of GET parameters. Now everything is simple: take the current query and add an array to it. Here is an example - let's say your current URL is domain.com/catalog from it you need to get a new URL, such as domain.com/catalog?category=1&order=price:
$request->fullUrlWithQuery(['category' => '1', 'order' => 'price']);
Voila!
3. Blade: continue and break
Now in the
foreach loop , you can interrupt or continue depending on the condition:
@foreach ($products as $product) @continue($product->category_id == 999) {{ $product->name }}: <b>{{ $product->price }}</b> @break($product->price >= 199) @endforeach
That's all for today!
Good luck to everyone in the projects. May the power of Laravel be with you.