if ($key == 'sts') { if ($row->{$key} == '1') { return ' Active'; } if ($row->{$key} == '0') { return ' Blocked'; } } if ($key == 'business_id') { if ($row->{$key} == '0') { return 'Admin'; } return get_business_name($row->{$key}); } if ($key == 'user_id') { if ($row->{$key} == '0') { return 'Admin'; } return get_user_name($row->{$key}); } if ($key == 'role_id') { if ($row->{$key} == '0') { return 'Admin'; } return get_role_name($row->{$key}); } if ($key == 'created_at') { return date('m/d/Y', strtotime($row->{$key})); } if ($key == 'price') { return '$'.$row->{$key}.''; } if ($key == 'image_path') { if($row->image_path){ if(!isset($myModArr['upload_folder'])){ $myModArr['upload_folder']=''; } $img=' Image '; } else{ $img='Image'; } return $img; } return $row->{$key}; } function mod_auto_arr($arr) { // For Making foreach ($arr as $key => $value) { // dd($arr,$key,$value); $stsNew = ''; if ($value == 'sts') { $stsNew = 'Status'; } else if ($value == 'created_at') { $stsNew = 'Date'; } else if ($value == 'id') { $stsNew = 'ID'; } else if ($value == 'user_id') { $stsNew = 'User Name'; } else if ($value == 'business_id') { $stsNew = 'Business'; } else { $stsNew = $value; } $arr[$key] = ucwords(str_replace('_', ' ', $stsNew)); } return $arr; } function mod_show_fields($key, $value, $db_value = '',$myModArr) { // For showing details on Show Page $value['label'] = mod_auto_arr([$value['label']])[0]; if ($key == 'role_id') { $value['value_arr'] = make_roles_Arr(); } if ($key == 'sts') { $value['value_arr'] = [1 => 'Active', 0 => 'Blocked']; return mod_show_html($value['label'], $value['value_arr'][$db_value] ?? $db_value); } $html = ''; if (in_array($value['type'], ['text', 'email', 'number', 'password', 'textarea', 'select'])) { return mod_show_html($value['label'], $db_value); } // For CheckBox elseif ($value['type'] == 'checkbox') { $checkArr = json_decode($db_value); $html .= implode(',', $checkArr); return mod_show_html($value['label'], $db_value); } // For Radio Buttons elseif ($value['type'] == 'radio') { // if($db_value=='1'){$html .='';} // if($db_value=='0'){$html .='';} return mod_show_html($value['label'], $value['value_arr'][$db_value] ?? ''); } elseif ($value['type'] == 'tick_cross') { $html = ''; if ($db_value == '1') { $html .= ''; } if ($db_value == '0') { $html .= ''; } return mod_show_html($value['label'], $html); } elseif ($value['type'] == 'file') { if($db_value){ $img=' Image '; } else{ $img='Image'; } return mod_show_html($value['label'], $img); } return mod_show_html($value['label'], $db_value); } function mod_show_html($fieldName, $fieldValue) { return '
' . $fieldName . ':
' . $fieldValue . '
'; } function mod_show_html2($fieldName, $fieldValue) { return '
  • '.$fieldName.''.$fieldValue.'
  • '; } function mod_build_checbox($key, $value, $array = []) { if (!is_array($array)) { $array = []; } return mod_build_fields($key, $value, json_encode($array)); } function make_roles_Arr() { $rolesArr = []; $roles = AccessRole::buss()->get(); foreach ($roles as $key => $value) { $rolesArr[$value->id] = $value->name; } return $rolesArr; } function mod_build_fields_add($key, $value,$grid_col='') { // This method is used , if we need to set a value in in Create page. return mod_build_fields($key, $value, $value['d_val'] ?? '',$grid_col); } function mod_build_fields($key, $value, $db_value = '',$col='12') { // Details related to Indexes is available on Live PB Docs. Please check if you feel any confusion. // dd($value); $value['label'] = mod_auto_arr([$value['label']])[0]; if ($key == 'role_id') { $value['value_arr'] = make_roles_Arr(); } if ($key == 'sts') { $value['value_arr'] = [1 => 'Active', 0 => 'Blocked']; } $html = ''; if (in_array($value['type'], ['text', 'email', 'number', 'password','hidden'])) { $html = ''; $inputF=''; // For Input Group Addon (Prepend) if(isset($value['left_addon']) && isset($value['right_addon'])){ $html.='
    '; $html.=''.$value['left_addon'].''; $html.=$inputF; $html.=''.$value['right_addon'].''; $html.='
    '; } elseif(isset($value['left_addon']) && $value['left_addon']!=''){ $html.='
    '.$value['left_addon'].''; $html.=$inputF; $html.='
    '; } elseif(isset($value['right_addon']) && $value['right_addon']!=''){ $html.='
    '; $html.=$inputF; $html.=''.$value['right_addon'].''; $html.='
    '; } else{ $html.=$inputF; } } // For TextArea elseif ($value['type'] == 'textarea') { $html = ' '; } // For Image/File elseif ($value['type'] == 'file') { $key = 'image_path'; $html = '
    '; } // For Select Options elseif ($value['type'] == 'select') { $html .= ''; $html .= ''; } elseif ($value['type'] == 'select2') { $html .= ''; $html .= ''; } // For CheckBox elseif ($value['type'] == 'checkbox') { $html .= ''; $html .= '
    '; foreach ($value['value_arr'] as $key2 => $val2) { $selected = ''; $checkArr = json_decode($db_value); if (is_array($checkArr) && in_array($key2, $checkArr)) { $selected = 'checked="checked"'; } $html .= ' ' . $val2 . ' '; } $html .= '
    '; } elseif ($value['type'] == 'checkbox_comma') { $html .= ''; $html .= '
    '; foreach ($value['value_arr'] as $key2 => $val2) { $selected = ''; $checkArr = explode(',',$db_value); if (is_array($checkArr) && in_array($key2, $checkArr)) { $selected = 'checked="checked"'; } $html .= ' ' . $val2 . ' '; } $html .= '
    '; } // For Radio Buttons elseif ($value['type'] == 'radio') { $html .= '

    '; foreach ($value['value_arr'] as $key2 => $val2) { $selected = ''; if ($key2 == $db_value) { $selected = 'checked="checked"'; } $html .= ''; } } $html2 = '
    ' . $html . '
    '; return $html2; } function mod_mask($key = '') { $msgArr = array( 'zip' => 'data-inputmask=\'"mask": "99999"\'', 'phone' => 'data-inputmask="\'mask\': [\'999-999-9999\']"', 'ssn' => 'data-inputmask="\'mask\': [\'999-99-9999\']"', ); if (array_key_exists($key, $msgArr)) { return $msgArr[$key] . ' data-mask '; } return '.:Action Performed Successfully'; } function mod_auto_value($key) { return mod_auto_arr([$key])[0]; } /* ========================================================================= */ /* ================= MOD Functions Ends Here ==================== */ /* ========================================================================= */