/** * 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; }
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'); }
/** * Sort the array using the given Closure. * * @param array $array * @param \Closure $callback * @return array */ function array_sort($array, Closure $callback) { return \Support\Collection::make($array)->sortBy($callback)->all(); }
/** * Sort the array using the given Closure. * * @param array $array * @param \Closure $callback * @return array */ public static function sort($array, Closure $callback) { return Collection::make($array)->sortBy($callback)->all(); }
/** * 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(); }