March 3rd ʼ21 1 year ago
use Illuminate\Support\Arr;
// Retrieving an item from a nested object
❌ $user->team->subscription->name;
✅ object_get($user, 'team.subscription.name', 'default value');
// Retrieving an item from a nested array
❌ $data['user']['team']['subscription']['name'];
✅ Arr::get($data, 'user.team.subscription.name', 'default value');