86 lines
No EOL
1.8 KiB
PHP
86 lines
No EOL
1.8 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 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 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($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);
|
|
}
|
|
|
|
} |