public static function put_data_field($item, $field, $input, $lang_code = 'es') { $field_name = $field->name; if (is_array($input)) { $final_input = json_encode($input); if ($field->type == 'image' || $field->type == 'file') { \Solunes\Master\App\TempFile::where('type', $field->type)->whereIn('file', $input)->delete(); } } else { if ($input && ($field->type == 'image' || $field->type == 'file')) { \Solunes\Master\App\TempFile::where('type', $field->type)->where('file', $input)->delete(); } $final_input = $input; } if (is_string($final_input) && trim($final_input) === '') { $final_input = NULL; } $item = \FuncNode::put_in_database($item, $field, $field_name, $final_input, $lang_code); return $item; }
public static function delete_temp($type = NULL, $folder = NULL, $file = NULL) { if ($type && $folder && $file) { $temp_files = \Solunes\Master\App\TempFile::where('type', $type)->where('folder', $folder)->where('file', $file)->get(); } else { $date = date('Y-m-d H:i:s', strtotime(' -1 day')); $temp_files = \Solunes\Master\App\TempFile::where('created_at', '<', $date)->get(); } if (count($temp_files) > 0) { foreach ($temp_files as $temp) { \Asset::delete_file($temp->type, $temp->folder, $temp->file); $temp->delete(); } } else { if ($type && $folder && $file) { \Asset::delete_file($type, $folder, $file); } } return true; }