DEV Community

Morcos Gad
Morcos Gad

Posted on • Edited on

1

New Things Added - Laravel 9.13 Released

Let's get started quickly I found new things in Laravel 9.13 Released I wanted to share with you.

method to the Collection class, which gets a single key's value from the first matching item in the collection

$c = new $collection([
    ['id' => 1, 'name' => 'Hello'],
    ['id' => 2, 'name' => 'World']
]);

$this->assertEquals('Hello', $c->value('name'));
$this->assertEquals('World', $c->where('id', 2)->value('name'));
Enter fullscreen mode Exit fullscreen mode
  • Array map() Method
$data = ['first' => 'taylor', 'last' => 'otwell'];
$mapped = Arr::map($data, function ($value, $key) {
    return $key.'-'.strrev($value);
});
Enter fullscreen mode Exit fullscreen mode
  • Test Response collect() Method

collect() method to the TestResponse class to get the JSON-decoded body of the response as a collection

$response->collect();

/*
Given the following array of data for a JSON response
[
    'foo' => ['foobar_foo' => 'foo', 'foobar_bar' => 'bar'],
    ...
];
*/

$response->collect('foo')

// Returns a collection instance with:
// ['foobar_foo' => 'foo', 'foobar_bar' => 'bar']
Enter fullscreen mode Exit fullscreen mode
$this->getJson('/users/1')
    ->assertOk()
    ->assertJsonMissingPath('email'); // Never return the user email

$this->getJson('/articles')
    ->assertOk()
    ->assertJsonMissingPath('data.0.internalTags');
Enter fullscreen mode Exit fullscreen mode
Notification::assertCount(4) // any number 
Enter fullscreen mode Exit fullscreen mode

I hope you enjoyed with me and to learn more about this release visit the sources and search more. I adore you who search for everything new.
Source :- https://laravel-news.com/laravel-9-13-0
Source :- https://www.youtube.com/watch?v=8BVnn0qezM8

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay