芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/public_html/invoicer.pulsehost.co.uk/app/Space/helpers.php
precision, $currency->decimal_separator, $currency->thousand_separator ); $currency_with_symbol = ''; if ($currency->swap_currency_symbol) { $currency_with_symbol = $format_money.'
'.$currency->symbol.'
'; } else { $currency_with_symbol = '
'.$currency->symbol.'
'.$format_money; } return $currency_with_symbol; } /** * @param $string * @return string */ function clean_slug($model, $title, $id = 0) { // Normalize the title $slug = Str::upper('CUSTOM_'.$model.'_'.Str::slug($title, '_')); // Get any that could possibly be related. // This cuts the queries down by doing it once. $allSlugs = getRelatedSlugs($model, $slug, $id); // If we haven't used it before then we are all good. if (! $allSlugs->contains('slug', $slug)) { return $slug; } // Just append numbers like a savage until we find not used. for ($i = 1; $i <= 10; $i++) { $newSlug = $slug.'_'.$i; if (! $allSlugs->contains('slug', $newSlug)) { return $newSlug; } } throw new \Exception('Can not create a unique slug'); } function getRelatedSlugs($type, $slug, $id = 0) { return CustomField::select('slug')->where('slug', 'like', $slug.'%') ->where('model_type', $type) ->where('id', '<>', $id) ->get(); } function respondJson($error, $message) { return response()->json([ 'error' => $error, 'message' => $message, ], 422); }