118 lines
No EOL
2.7 KiB
PHP
118 lines
No EOL
2.7 KiB
PHP
<?php
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
class Util
|
|
{
|
|
|
|
|
|
|
|
private static $postRoute = 'base.';
|
|
|
|
public static function getToken()
|
|
{
|
|
return hash_hmac('sha256', str_random(40), config('app.key'));
|
|
}
|
|
|
|
public static function formatDate(){
|
|
if(\App::getLocale() == "en"){
|
|
return 'yyyy-mm-dd';
|
|
}
|
|
return 'dd.mm.yyyy';
|
|
|
|
}
|
|
|
|
public static function formatDateDB(){
|
|
if(\App::getLocale() == "en"){
|
|
return 'Y-m-d';
|
|
}
|
|
return 'd.m.Y';
|
|
}
|
|
|
|
public static function formatDateTimeDB(){
|
|
if(\App::getLocale() == "en"){
|
|
return 'Y-m-d - H:i';
|
|
}
|
|
return 'd.m.Y - H:i';
|
|
}
|
|
|
|
public static function utf8ize( $mixed ) {
|
|
if (is_array($mixed)) {
|
|
foreach ($mixed as $key => $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 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 getUserShopBackUrl($reference = ""){
|
|
|
|
if(\Session::has('user_shop')){
|
|
if($user_shop = \Session::get('user_shop')){
|
|
return 'http://'.$user_shop->slug.".".Config('app.domain')."/back/to/shop/".$reference;
|
|
}
|
|
}
|
|
return url("/");
|
|
}
|
|
|
|
public static function getUserCardBackUrl($uri){
|
|
|
|
if(\Session::has('user_shop')){
|
|
if($user_shop = \Session::get('user_shop')){
|
|
return 'http://'.$user_shop->slug.".".Config('app.domain').$uri;
|
|
}
|
|
}
|
|
return url($uri);
|
|
}
|
|
|
|
} |