Ejemplo n.º 1
1
 /**
  * Get an item from an array or object using "dot" notation.
  *
  * @param  mixed   $target
  * @param  string|array  $key
  * @param  mixed   $default
  * @return mixed
  */
 function data_get($target, $key, $default = null)
 {
     if (is_null($key)) {
         return $target;
     }
     $key = is_array($key) ? $key : explode('.', $key);
     while (($segment = array_shift($key)) !== null) {
         if ($segment === '*') {
             if ($target instanceof Collection) {
                 $target = $target->all();
             } elseif (!is_array($target)) {
                 return value($default);
             }
             $result = Arr::pluck($target, $key);
             return in_array('*', $key) ? Arr::collapse($result) : $result;
         }
         if (Arr::accessible($target) && Arr::exists($target, $segment)) {
             $target = $target[$segment];
         } elseif (is_object($target) && isset($target->{$segment})) {
             $target = $target->{$segment};
         } else {
             return value($default);
         }
     }
     return $target;
 }
Ejemplo n.º 2
0
 /**
  * @return $this
  */
 public function init()
 {
     $config = Arr::collapse([$this->loadIlluminateConfiguration(), $this->loadFiledConfiguration()]);
     $this->application->instance('env', 'production');
     $this->application->instance('config', new Repository($config));
     $this->application->registerConfiguredProviders();
     $this->application->singleton(HttpKernelContract::class, HttpKernel::class);
     $this->application->singleton(ConsoleKernelContract::class, ConsoleKernel::class);
     $this->application->singleton(ExceptionHandler::class, Handler::class);
     if ($this->application->isInstalled()) {
         $this->application->register(ThemeServiceProvider::class);
         $this->application->register(MenuServiceProvider::class);
         $this->application->register(CategoryServiceProvider::class);
         $this->application->register(ArticleServiceProvider::class);
         $this->application->register(HttpServiceProvider::class);
         $this->application->register(PageServiceProvider::class);
         $this->application->register(AdminServiceProvider::class);
     } else {
         $this->application->register(InstallServiceProvider::class);
     }
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * Collapse the collection of items into a single array.
  *
  * @return static
  */
 public function collapse()
 {
     return new static(Arr::collapse($this->items));
 }
Ejemplo n.º 4
0
 /**
  * Collapse an array of arrays into a single array.
  *
  * @param  array|\ArrayAccess  $array
  * @return array
  */
 function array_collapse($array)
 {
     return Arr::collapse($array);
 }