where('group',request()->group)->get(); foreach ($customFields as $customField){ $key=$customField['key']; $options=$customField->options; $inputs=$customField->inputs; $type=CustomFieldType::from($customField->type)->name; if($customField->type==3){ foreach ($options as $option){ $customKey=$option['lang']['en']; $customValue=$option['value']; $objects->push($this->formatRow($key,$type,$customKey,$customValue)); } } if($customField->type==1){ foreach ($inputs as $input){ $customKey=$input['lang']['en']; $customValue=$input['value']; $objects->push($this->formatRow($key,$type,$customKey,$customValue)); } } $objects->push($this->formatRow('','','','')); } return $objects; // TODO: Implement collection() method. } protected function formatRow($key,$type,$customKey,$customValue) { return [ $key, $type, $customKey, $customValue, ]; } public function headings(): array { return [ 'key', 'type', 'customKey', 'customValue', ]; } }