コード例 #1
0
ファイル: helpers.php プロジェクト: nova-framework/system
 /**
  * Create a collection from the given value.
  *
  * @param  mixed  $value
  * @return \Nova\Support\Collection
  */
 function collect($value = null)
 {
     return Collection::make($value);
 }
コード例 #2
0
ファイル: ModuleManager.php プロジェクト: nova-framework/cms
 public function getModules()
 {
     if (isset(static::$modules)) {
         return static::$modules;
     }
     //
     $modules = $this->config->get('modules.modules', array());
     $modules = array_map(function ($slug, $properties) {
         $autoload = array('config', 'events', 'filters', 'routes');
         $options = array_get($properties, 'autoload', array());
         if (!empty($options)) {
             $autoload = array_intersect($options, $autoload);
         }
         array_push($autoload, 'bootstrap');
         //
         $namespace = isset($properties['namespace']) ? $properties['namespace'] : Str::studly($slug);
         return array_merge(array('slug' => $slug, 'name' => isset($properties['name']) ? $properties['name'] : $namespace, 'namespace' => $namespace, 'enabled' => isset($properties['enabled']) ? $properties['enabled'] : true, 'order' => isset($properties['order']) ? $properties['order'] : 9001, 'autoload' => $autoload), $properties);
     }, array_keys($modules), $modules);
     return static::$modules = Collection::make($modules)->sortBy('order');
 }
コード例 #3
0
ファイル: MorphTo.php プロジェクト: nova-framework/cms
 /**
  * Gather all of the foreign keys for a given type.
  *
  * @param  string  $type
  * @return array
  */
 protected function gatherKeysByType($type)
 {
     $foreign = $this->foreignKey;
     return BaseCollection::make($this->dictionary[$type])->map(function ($models) use($foreign) {
         return head($models)->{$foreign};
     })->unique();
 }
コード例 #4
0
ファイル: Builder.php プロジェクト: nova-framework/system
 /**
  * Get an array with the values of a given column.
  *
  * @param  string  $column
  * @param  string  $key
  * @return array
  */
 public function lists($column, $key = null)
 {
     $columns = $this->getListSelect($column, $key);
     // First we will just get all of the column values for the record result set
     // then we can associate those values with the column if it was specified
     // otherwise we can just give these values back without a specific key.
     $results = new Collection($this->get($columns));
     $values = $results->fetch($columns[0])->all();
     // If a key was specified and we have results, we will go ahead and combine
     // the values with the keys of all of the records so that the values can
     // be accessed by the key of the rows instead of simply being numeric.
     if (!is_null($key) && count($results) > 0) {
         $keys = $results->fetch($key)->all();
         return array_combine($keys, $values);
     }
     return $values;
 }
コード例 #5
0
ファイル: Builder.php プロジェクト: nova-framework/cms
 /**
  * Get an array with the values of a given column.
  *
  * @param  string  $column
  * @param  string  $key
  * @return array
  */
 public function lists($column, $key = null)
 {
     $columns = $this->getListSelect($column, $key);
     //
     $results = new Collection($this->get($columns));
     $values = $results->fetch($columns[0])->all();
     if (!is_null($key) && count($results) > 0) {
         $keys = $results->fetch($key)->all();
         return array_combine($keys, $values);
     }
     return $values;
 }