Edit File: helper.php
<?php use App\Models\Seo; use App\Models\SiteSetting; function seo($key) { return Seo::where('key', $key)->first(); } function appInformations() { return SiteSetting::pluck('value', 'key'); } function convert2english($string) { $newNumbers = range(0, 9); $arabic = array('٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'); $string = str_replace($arabic, $newNumbers, $string); return $string; } function fixPhone($string = null) { if (!$string) { return null; } $result = convert2english($string); $result = ltrim($result, '00'); $result = ltrim($result, '0'); $result = ltrim($result, '+'); return $result; } function getPhone($code, $phone) { return fixPhone($code) . fixPhone($phone); } function getYoutubeVideoId($youtubeUrl) { preg_match( "/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $youtubeUrl, $videoId ); return isset($videoId[1]) ? $videoId[1] : ""; } function lang() { return App()->getLocale(); } function generateRandomCode() { return rand(1111, 4444); } if (!function_exists('languages')) { function languages() { return ['ar', 'en']; } } if (!function_exists('defaultLang')) { function defaultLang() { return 'ar'; } } if (!function_exists('currentLang')) { function currentLang() { // get lang of user's current device $user = auth()->user(); if ($user?->currentDevice) { return $user->currentDevice->preferred_locale; } return defaultLang(); } } if (!function_exists('isEmail')) { function isEmail($input) { return filter_var($input, FILTER_VALIDATE_EMAIL) !== false; } } if (!function_exists('getFlag')) { function getFlags() { $flags = []; foreach (\File::files(public_path('admin/assets/flags/png')) as $path) { $file = pathinfo($path); $flags[] = $file['filename'] . '.' . $file['extension']; } return $flags; } }
Back to File Manager