$value) { $mixed[$key] = self::utf8ize($value); } } elseif (is_string($mixed)) { return mb_convert_encoding($mixed, "UTF-8", "UTF-8"); } return $mixed; } public static function getPostRoute(){ return self::$postRoute; } public static function setPostRoute($postRoute){ self::$postRoute = $postRoute; } public static function getUserShop(){ if(\Session::has('user_shop')){ if($user_shop = \Session::get('user_shop')){ return $user_shop; } } return false; } public static function getAuthUser(){ if(\Session::has('auth_user')){ if($auth_user = \Session::get('auth_user')){ return $auth_user; } } return false; } public static function getUserShopIdentifier(){ if(\Session::has('user_shop_identifier')){ if($user_shop_identifier = \Session::get('user_shop_identifier')){ return $user_shop_identifier; } } return false; } public static function getUserHistory(){ $auth_user = self::getAuthUser(); $user_shop_identifier = self::getUserShopIdentifier(); if($user_shop_identifier && $auth_user){ return UserHistory::whereUserId($auth_user->id)->whereIdentifier($user_shop_identifier)->get()->last(); } return false; } public static function setUserHistoryValue($values = []){ if($user_history = self::getUserHistory()){ foreach ($values as $key=>$val){ $user_history->{$key} = $val; } $user_history->save(); } } public static function getUserHistoryValue($key){ if($user_history = self::getUserHistory()) { return $user_history->{$key}; } return null; } public static function getUserShoppingMode(){ if($auth_user = self::getAuthUser()){ if($auth_user->isTestMode()){ return 'test'; } } return 'live'; } public static function addRoute($p = []){ $b = []; if(\Session::has('user_shop')){ if($user_shop = \Session::get('user_shop')){ $b = ['subdomain' => $user_shop->slug]; } } return array_merge($p, $b); } public static function isCheckout(){ if(\Session::has('isCheckout')){ if(\Session::get('isCheckout') == true){ return true; } } return false; } public static function getMyMivitaUrl($protocol = true){ $pro = $protocol ? config('app.protocol') : ""; return $pro.config('app.pre_url_crm').config('app.domain').config('app.tld_care'); } public static function getUserPaymentFor(){ if(\Session::has('user_shop_payment')){ return \Session::get('user_shop_payment'); } return null; } public static function getUserShopBackUrl($reference = ""){ if(\Session::has('user_shop')){ if(\Session::has('user_shop_domain')){ return \Session::get('user_shop_domain'); } if($user_shop = \Session::get('user_shop')){ return config('app.protocol').$user_shop->slug.".".config('app.domain').config('app.tld_care')."/back/to/shop/".$reference; } } return url("/"); } public static function getUserCardBackUrl($uri){ if(\Session::has('user_shop')){ if(\Session::has('user_shop_domain')){ if(self::getUserPaymentFor() === 3){ return \Session::get('user_shop_domain')."/user/membership"; } if(self::getUserPaymentFor() === 2){ return \Session::get('user_shop_domain')."/user/orders"; } return \Session::get('user_shop_domain'); } if($user_shop = \Session::get('user_shop')){ return config('app.protocol').$user_shop->slug.".".config('app.domain').config('app.tld_care').$uri; } } return url($uri); } public static function sanitize($string, $force_lowercase = true, $anal = false, $substr = false) { $strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]", "}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—", "—", "–", ",", "<", ".", ">", "/", "?"); $clean = trim(str_replace($strip, "", strip_tags($string))); $clean = preg_replace('/\s+/', "_", $clean); $clean = ($anal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ; if($substr){ $clean = (strlen($clean) > 20) ? substr($clean,-20) : $clean; } return ($force_lowercase) ? (function_exists('mb_strtolower')) ? mb_strtolower($clean, 'UTF-8') : strtolower($clean) : $clean; } }