示例#1
0
 /**
  * Template URL helper
  * @param string $path
  * @param string $template
  * @return string
  */
 function template_url($path, $template = null)
 {
     $config = app('config');
     $template = $template ?: $config['app']['template'];
     if ('adminlte' == Str::lower($template)) {
         $template = 'adminlte';
     } else {
         if (Str::length($template) > 3) {
             $template = Str::snake($template, '-');
         } else {
             $template = Str::lower($template);
         }
     }
     $path = sprintf('templates/%s/assets/%s', $template, ltrim($path, '/'));
     return url($path);
 }
示例#2
0
 /**
  * Convert a string to snake case.
  *
  * @param  string  $value
  * @param  string  $delimiter
  * @return string
  */
 function snake_case($value, $delimiter = '_')
 {
     return Str::snake($value, $delimiter);
 }
示例#3
0
 /**
  * Get the model's relationships in array form.
  *
  * @return array
  */
 public function relationsToArray()
 {
     $attributes = array();
     foreach ($this->getArrayableRelations() as $key => $value) {
         if (in_array($key, $this->hidden)) {
             continue;
         }
         if ($value instanceof ArrayableInterface) {
             $relation = $value->toArray();
         } else {
             if (is_null($value)) {
                 $relation = $value;
             }
         }
         if (static::$snakeAttributes) {
             $key = Str::snake($key);
         }
         if (isset($relation) || is_null($value)) {
             $attributes[$key] = $relation;
         }
         unset($relation);
     }
     return $attributes;
 }
示例#4
0
 /**
  * Dynamically bind flash data in the session.
  *
  * @param  string  $method
  * @param  array  $parameters
  * @return void
  *
  * @throws \BadMethodCallException
  */
 public function __call($method, $parameters)
 {
     if (str_starts_with($method, 'with')) {
         return $this->with(Str::snake(substr($method, 4)), $parameters[0]);
     }
     throw new \BadMethodCallException("Method [{$method}] does not exist on Redirect.");
 }
示例#5
0
 /**
  * Get the Table for the Model.
  *
  * @return string
  */
 public function getTable()
 {
     if (isset($this->table)) {
         return $this->table;
     }
     return str_replace('\\', '', Str::snake(class_basename($this)));
 }
示例#6
0
 /**
  * Handle dynamic calls to class methods.
  *
  * @param  string  $method
  * @param  array   $parameters
  * @return mixed
  *
  * @throws \BadMethodCallException
  */
 public function __call($method, $parameters)
 {
     $rule = Str::snake(substr($method, 8));
     if (isset($this->extensions[$rule])) {
         return $this->callExtension($rule, $parameters);
     }
     throw new \BadMethodCallException("Method [{$method}] does not exist.");
 }
示例#7
0
 /**
  * Add a single dynamic where clause statement to the query.
  *
  * @param  string  $segment
  * @param  string  $connector
  * @param  array   $parameters
  * @param  int     $index
  * @return void
  */
 protected function addDynamic($segment, $connector, $parameters, $index)
 {
     $bool = strtolower($connector);
     $this->where(Str::snake($segment), '=', $parameters[$index], $bool);
 }