| Server IP : 13.235.167.51 / Your IP : 216.73.217.116 Web Server : Apache System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64 User : root ( 0) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/app.machinox.in/app/Helpers/ |
Upload File : |
<?php
namespace App\Helpers;
use App\Models\Store;
use App\Models\StoreReservationSlot;
use App\Models\StoreReservationTiming;
use App\Models\UserOffers;
use App\Traits\UploadTrait;
use Carbon\Carbon;
use chillerlan\QRCode\Output\QRGdImagePNG;
use chillerlan\QRCode\Output\QROutputInterface;
use chillerlan\QRCode\QRCode;
use chillerlan\QRCode\QROptions;
use DateTime;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
class UtilityHelper
{
use UploadTrait;
public static function getCurrencyExchangeRates()
{
$res = Http::accept("application/json")->get("https://www.floatrates.com/daily/usd.json");
if ($res->successful()) {
return ["status" => true, "list" => $res->json(), "status_code" => $res->status()];
}
if ($res->failed()) {
return ["status" => false, "info" => $res->json(), "status_code" => $res->status()];
}
}
public static function GetImageBaseName($url)
{
$url = urldecode($url);
$baseURL = explode("?", $url)[0];
$baseName = pathinfo($baseURL, PATHINFO_BASENAME);
return $baseName;
}
public static function getChanges($obj)
{
$changes = [];
if (!$obj->wasRecentlyCreated) {
$original = $obj->getOriginal();
foreach ($obj->getChanges() as $key => $value) {
$changes[$key] = [
'original' => $original[$key],
'changes' => $value,
];
}
}
return $changes;
}
public static function verifyTestMobileNumber($phone): bool
{
if (
(substr($phone, 0, 9) == '999999999')
|| (substr($phone, 0, 9) == '888888888')
|| (substr($phone, 0, 9) == '777777777')
|| (substr($phone, -5) == '00000')
|| (substr($phone, -5) == '12345')
|| (substr($phone, -5) == '11111')
) {
return false;
}
return true;
}
/**
* Returns a locale from a country code that is provided.
*
* @param $country_code ISO 3166-2-alpha 2 country code
* @param $language_code ISO 639-1-alpha 2 language code
* @returns a locale, formatted like en_US, or null if not found
*
**/
public static function FormatAmount($amount, $currency_code, $locale)
{
$fmt = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
$fmt->setTextAttribute(\NumberFormatter::CURRENCY_CODE, $currency_code);
$fmt->setAttribute(\NumberFormatter::FRACTION_DIGITS, 2);
return $fmt->formatCurrency($amount, $currency_code);
}
public static function calculateDate($planType)
{
$fromDate = date('Y-m-d');
switch ($planType) {
case 'MONTHLY':
$toDate = date("Y-m-d", strtotime("+29 day", strtotime($fromDate)));
break;
case 'QUARTERLY':
$toDate = date("Y-m-d", strtotime("+89 day", strtotime($fromDate)));
break;
case 'HALFYEARLY':
$toDate = date("Y-m-d", strtotime("+182 day", strtotime($fromDate)));
break;
case 'YEARLY':
$toDate = date("Y-m-d", strtotime("+365 day", strtotime($fromDate)));
break;
default:
return 'Invalid plan type';
}
$date1 = new DateTime($fromDate);
$date2 = new DateTime($toDate);
$interval = $date1->diff($date2);
$totalDays = $interval->days;
return [
'start_date' => $fromDate,
'end_date' => $toDate,
'total_days' => $totalDays
];
}
public static function GetDocumentURL($folder, $value)
{
if ($value) {
if (Str::startsWith("http", $value)) {
return $value;
} else {
$disk = config("filesystems.default");
Log::info("disk Info " . $disk);
if (Storage::disk($disk)->exists($folder . '/' . $value)) {
if ($disk == 's3') {
return Storage::disk($disk)->temporaryUrl($folder . "/" . $value, now()->addMinutes(10));
} else {
return Storage::disk($disk)->url($folder . "/" . $value);
}
}
}
}
return $value;
}
}