Posted: 26-03-2018

Check if property is set and not empty using Laravel data_get() helper

Check if property is set and not empty using Laravel data_get() helper

Using the data_get() helper function you can easy validate if a property is set and not empty.

if (isset($this->config['whereFilter']) && $this->config['whereFilter'] != '') {
return $objBuilder->whereRaw($this->config['whereFilter']); }

with data_get() 

if (data_get($this->config,'whereFilter')) {
$objBuilder->whereRaw($this->config['whereFilter']);
};