123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- if (!function_exists('getDomain')) {
-
- function getDomain() {
- return request()->getSchemeAndHttpHost();
- }
- }
- if (!function_exists('getHost')) {
-
- function getHost() {
- return request()->getHost();
- }
- }
- if (!function_exists('getDistId')) {
- function getDistId() {
- return app('dist')->id;
- }
- }
- if (!function_exists('formatDirectory')) {
-
- function formatDirectory($directory) {
-
- if (empty($directory)) {
- return '';
- }
-
- $directory = ltrim($directory, '/');
-
- $directory = rtrim($directory, '/') . '/';
- return $directory;
- }
- }
- if (!function_exists('formatAndCreateAbsoluteDirectory')) {
-
- function formatAndCreateAbsoluteDirectory($path, $permissions = 0755) {
-
- if (empty($path)) {
- return '';
- }
-
-
- if (preg_match('/\/[^\/]+\.[^\/]+$/', $path)) {
-
- $path = dirname($path);
- }
-
- $path = rtrim($path, '/') . '/';
-
- if (!is_dir($path)) {
- if (!mkdir($path, $permissions, true)) {
- throw new Exception("Failed to create directory: {$path}");
- }
- }
- return $path;
- }
- }
- if (!function_exists('generateOrderNumber')) {
-
- function generateOrderNumber($prefix = 'ORD') {
-
- $date = date('YmdHis');
-
- $randomNumber = mt_rand(10, 99);
-
- $orderNumber = $prefix . $date . $randomNumber;
- return $orderNumber;
- }
- }
|