@php $uCard = auth()->user(); $pCard = optional($uCard->profile); $settings = \App\Models\CardSettings::where('activity_id', $activity->id)->first(); $card = optional($settings)->card_setting ?? []; $cardConf = $card['card'] ?? []; $cardWidthPx = $cardConf['width_px'] ?? (isset($cardConf['width_cm']) ? round($cardConf['width_cm'] * 37.8) : round(5.27 * 37.8)); $cardHeightPx = $cardConf['height_px'] ?? (isset($cardConf['height_cm']) ? round($cardConf['height_cm'] * 37.8) : round(8.6 * 37.8)); $bgFile = $cardConf['background'] ?? null; function styleFrom($arr){ if (!is_array($arr)) return ''; $s = []; foreach ([["left","px"],["top","px"],["width","px"],["height","px"]] as $k){ if (isset($arr[$k[0]]) && is_numeric($arr[$k[0]])) $s[] = $k[0].':'.$arr[$k[0]].$k[1]; } return implode(';', $s); } function stylePos($arr, $cardWidthPx, $cardHeightPx){ if (!is_array($arr)) return ''; $cW = max(0, $cardWidthPx); $cH = max(0, $cardHeightPx); $left = null; $top = null; $width = null; $height = null; if (isset($arr['left']) && is_numeric($arr['left'])) { $left = (int)$arr['left']; } elseif (isset($arr['left_ratio']) && is_numeric($arr['left_ratio'])) { $left = (int)round($arr['left_ratio'] * $cW); } if (isset($arr['top']) && is_numeric($arr['top'])) { $top = (int)$arr['top']; } elseif (isset($arr['top_ratio']) && is_numeric($arr['top_ratio'])) { $top = (int)round($arr['top_ratio'] * $cH); } if (isset($arr['width']) && is_numeric($arr['width'])) { $width = (int)$arr['width']; } elseif (isset($arr['width_ratio']) && is_numeric($arr['width_ratio'])) { $width = (int)round($arr['width_ratio'] * $cW); } if (isset($arr['height']) && is_numeric($arr['height'])) { $height = (int)$arr['height']; } elseif (isset($arr['height_ratio']) && is_numeric($arr['height_ratio'])) { $height = (int)round($arr['height_ratio'] * $cH); } $s = []; if ($left !== null) $s[] = 'left:'.$left.'px'; if ($top !== null) $s[] = 'top:'.$top.'px'; if ($width !== null) $s[] = 'width:'.$width.'px'; if ($height !== null) $s[] = 'height:'.$height.'px'; if (isset($arr['style_inline']) && is_string($arr['style_inline'])) $s[] = trim($arr['style_inline']); return implode(';', $s); } function textCssFrom($arr){ if (!is_array($arr)) return ''; $s = []; if (!empty($arr['color'])) $s[] = 'color:'.$arr['color']; if (!empty($arr['font'])) $s[] = 'font-family:'.$arr['font']; if (!empty($arr['size'])) $s[] = 'font-size:'.((int)$arr['size']).'px'; if (!empty($arr['align'])) $s[] = 'text-align:'.$arr['align']; if (!empty($arr['weight'])) $s[] = 'font-weight:'.$arr['weight']; if (!empty($arr['italic'])) $s[] = 'font-style:'.$arr['italic']; if (!empty($arr['width'])) $s[] = 'width:'.((int)$arr['width']).'px'; return implode(';', $s); } function visibilityFrom($arr){ if (!is_array($arr)) return ''; if (array_key_exists('visible', $arr) && !$arr['visible']) return 'display:none'; return ''; } function rgbaOverlay($hex, $opacity){ if (!$hex || $opacity === null) return 'transparent'; $hex = ltrim($hex,'#'); if (strlen($hex)===3) $hex = $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2]; $r = hexdec(substr($hex,0,2)); $g = hexdec(substr($hex,2,2)); $b = hexdec(substr($hex,4,2)); $a = max(0,min(1, (int)$opacity/100 )); return "rgba($r,$g,$b,$a)"; } @endphp @if(empty($render_partial))
@endif