123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- <?php
- use Illuminate\Support\MessageBag;
- if (!function_exists('admin_path')) {
- /**
- * Get admin path.
- *
- * @param string $path
- *
- * @return string
- */
- function admin_path($path = '')
- {
- return ucfirst(config('admin.directory')).($path ? DIRECTORY_SEPARATOR.$path : $path);
- }
- }
- if (!function_exists('admin_url')) {
- /**
- * Get admin url.
- *
- * @param string $path
- * @param mixed $parameters
- * @param bool $secure
- *
- * @return string
- */
- function admin_url($path = '', $parameters = [], $secure = null)
- {
- if (\Illuminate\Support\Facades\URL::isValidUrl($path)) {
- return $path;
- }
- $secure = $secure ?: (config('admin.https') || config('admin.secure'));
- return url(admin_base_path($path), $parameters, $secure);
- }
- }
- if (!function_exists('admin_base_path')) {
- /**
- * Get admin url.
- *
- * @param string $path
- *
- * @return string
- */
- function admin_base_path($path = '')
- {
- $prefix = '/'.trim(config('admin.route.prefix'), '/');
- $prefix = ($prefix == '/') ? '' : $prefix;
- $path = trim($path, '/');
- if (is_null($path) || strlen($path) == 0) {
- return $prefix ?: '/';
- }
- return $prefix.'/'.$path;
- }
- }
- if (!function_exists('admin_toastr')) {
- /**
- * Flash a toastr message bag to session.
- *
- * @param string $message
- * @param string $type
- * @param array $options
- */
- function admin_toastr($message = '', $type = 'success', $options = [])
- {
- $toastr = new MessageBag(get_defined_vars());
- session()->flash('toastr', $toastr);
- }
- }
- if (!function_exists('admin_success')) {
- /**
- * Flash a success message bag to session.
- *
- * @param string $title
- * @param string $message
- */
- function admin_success($title, $message = '')
- {
- admin_info($title, $message, 'success');
- }
- }
- if (!function_exists('admin_error')) {
- /**
- * Flash a error message bag to session.
- *
- * @param string $title
- * @param string $message
- */
- function admin_error($title, $message = '')
- {
- admin_info($title, $message, 'error');
- }
- }
- if (!function_exists('admin_warning')) {
- /**
- * Flash a warning message bag to session.
- *
- * @param string $title
- * @param string $message
- */
- function admin_warning($title, $message = '')
- {
- admin_info($title, $message, 'warning');
- }
- }
- if (!function_exists('admin_info')) {
- /**
- * Flash a message bag to session.
- *
- * @param string $title
- * @param string $message
- * @param string $type
- */
- function admin_info($title, $message = '', $type = 'info')
- {
- $message = new MessageBag(get_defined_vars());
- session()->flash($type, $message);
- }
- }
- if (!function_exists('admin_asset')) {
- /**
- * @param $path
- *
- * @return string
- */
- function admin_asset($path)
- {
- return (config('admin.https') || config('admin.secure')) ? secure_asset($path) : asset($path);
- }
- }
- if (!function_exists('array_delete')) {
- /**
- * Delete from array by value.
- *
- * @param array $array
- * @param mixed $value
- */
- function array_delete(&$array, $value)
- {
- foreach ($array as $index => $item) {
- if ($value == $item) {
- unset($array[$index]);
- }
- }
- }
- }
|