Hello Artisan, did you know that There are helper methods in php laravel which makes easier to retrieve items from a deeply nested object or array. In this example i will show you that with source code.
Let assume we have a $user object which contains nested data. Now what we did?
$user->team->subscription->name
But we can do ot like below as well
object_get($user, 'team.subscription.name', 'default_value')
Now again let assume we have a $user array which contains nested data. Now what we did?
$data['user']['team']['subscription']['name']
But we can do ot like below as well
Arr::get($data,'user.team.subscription.name', 'your_default_data')
Recommended: Some Laravel Best Practices Every Developer Should Know
Hope it can help you.
#laravel #laravel-8x