Source: dev.to

Laravel data_get()
A função data_get() está presente na documentação do Laravel desde a versão 5.5 porém talvez você nunca a tenha usado. A função data_get() recupera o valor de um objeto ou matriz usando "dot" notation, e o melhor é que caso a chave passada não exista, não retornara erros de exceção, apenas null ou o valor default informado. exemplo: $data = ['products' => ['desk' => ['price' => 100]]]; $price = data_get($data, 'products.desk.price'); // 100 $price = data_get($data, 'products.desk.total_price'); // null Exit fullscreen mode exemplo utilizando request: $data = $request->all(); $price = data_get($data, 'products.desk.price'); // 100
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners