本文整理汇总了PHP中Illuminate\Support\Arr::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::has方法的具体用法?PHP Arr::has怎么用?PHP Arr::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Arr
的用法示例。
在下文中一共展示了Arr::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Processes LDAP search results and constructs their model instances.
*
* @param resource $results
*
* @return array
*/
public function process($results)
{
// Normalize entries. Get entries returns false on failure.
// We'll always want an array in this situation.
$entries = $this->connection->getEntries($results) ?: [];
if ($this->builder->isRaw()) {
// If the builder is asking for a raw
// LDAP result, we can return here.
return $entries;
}
$models = [];
if (Arr::has($entries, 'count')) {
for ($i = 0; $i < $entries['count']; $i++) {
// We'll go through each entry and construct a new
// model instance with the raw LDAP attributes.
$models[] = $this->newLdapEntry($entries[$i]);
}
}
if (!$this->builder->isPaginated()) {
// If the current query isn't paginated,
// we'll sort the models array here.
$models = $this->processSort($models);
}
return $models;
}
示例2: parse
/**
* Try to get the token from the route parameters.
*
* @param \Illuminate\Http\Request $request
*
* @return null|string
*/
public function parse(Request $request)
{
// WARNING: Only use this parser if you know what you're doing!
// It will only work with poorly-specified aspects of certain Lumen releases.
$route = $request->route();
if (is_array($route) && Arr::has($route, '2.' . $this->key)) {
// Route is the expected kind of array, and has a parameter with the key we want.
return $route[2][$this->key];
}
}
示例3: _buildTranslationKeys
/**
* Returns an array of translation keys specific to the currently requested controller/action.
*
* @param $namespace
* @param $group
* @param $item
* @return mixed
*/
protected function _buildTranslationKeys($namespace, $group, $item)
{
if (!Arr::has($this->_translationKeys, "{$namespace}.{$group}.{$item}")) {
$controller = "controller:{$this->_getController()}";
$action = "action:{$this->_getAction()}";
$key = "key:{$item}";
// The order of these matter. We always search from most specific to least specific.
Arr::set($this->_translationKeys, "{$namespace}.{$group}.{$item}", ["{$controller}_{$action}_{$key}", "{$action}_{$key}", "{$controller}_{$key}", "{$item}"]);
}
return Arr::get($this->_translationKeys, "{$namespace}.{$group}.{$item}");
}
示例4: has
/**
* Determine if a user exists in the repository.
*
* @param string $identification
* @param string $type Must be one of properties defined in User class
* @return bool
*/
public function has($identification, $type = 'uid')
{
if ($type == "uid") {
return Arr::has($this->items, $identification);
} else {
return Arr::where((array) $this->items, function ($key, $value) use($identification, $type) {
if (property_exists($value, $type)) {
return false;
}
return $value->{$type} == $identification;
});
}
}
示例5: all
public static function all($params = [])
{
$metadata = [];
$response = static::requestToArray('GET', null, $params);
if (Arr::has($response, 'metadata')) {
$metadata = Arr::pull($response, 'metadata');
$response = Arr::pull($response, 'data');
}
// Create collection of current class
$collection = Collection::makeOf(static::class, $response);
// Set metada property to main object
foreach ($metadata as $key => $value) {
$collection->{$key} = $value;
}
return $collection;
}
示例6: handle
/**
* Execute the console command.
*
* @return mixed
* @codeCoverageIgnore
*/
public function handle()
{
$time = time();
DB::connection('econt')->disableQueryLog();
$this->comment(PHP_EOL . 'Starting...');
$this->comment(PHP_EOL . 'Importing zones and settlements... Please wait.');
Zone::whereRaw(1)->delete();
Settlement::whereRaw(1)->delete();
foreach (App::make('Econt')->zones() as $zone) {
(new Zone())->import($zone);
$zone_id = Arr::has($zone, 'id') ? Arr::get($zone, 'id') : 0;
foreach (App::make('Econt')->settlements($zone_id) as $settlement) {
if (!is_array($settlement)) {
continue;
}
(new Settlement())->import($settlement);
}
}
$this->comment(PHP_EOL . 'Zones and settlements imported successfully.');
$this->comment(PHP_EOL . 'Importing regions... Please wait.');
Region::whereRaw(1)->delete();
foreach (App::make('Econt')->regions() as $region) {
(new Region())->import($region);
}
$this->comment(PHP_EOL . 'Regions imported successfully.' . PHP_EOL);
$this->comment(PHP_EOL . 'Importing neighbourhoods... Please wait.');
Neighbourhood::whereRaw(1)->delete();
foreach (App::make('Econt')->neighbourhoods() as $region) {
(new Neighbourhood())->import($region);
}
$this->comment(PHP_EOL . 'Neighbourhoods imported successfully.' . PHP_EOL);
$this->comment(PHP_EOL . 'Importing streets... Please wait.');
Street::whereRaw(1)->delete();
foreach (App::make('Econt')->streets() as $region) {
(new Street())->import($region);
}
$this->comment(PHP_EOL . 'Streets imported successfully.' . PHP_EOL);
$this->comment(PHP_EOL . 'Importing offices... Please wait.');
Office::whereRaw(1)->delete();
foreach (App::make('Econt')->offices() as $region) {
(new Office())->import($region);
}
$this->comment(PHP_EOL . 'Offices imported successfully.' . PHP_EOL);
$this->comment(PHP_EOL . sprintf('Finished in %f minutes.', (time() - $time) / 60));
}
示例7: syncKeysFromFiles
/**
* Synchronize keys found in project files but missing in languages.
*
* @param $translationFiles
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
* @return void
*/
private function syncKeysFromFiles($translationFiles)
{
$this->info('Reading translation keys from files...');
// An array of all translation keys as found in project files.
$allKeysInFiles = $this->manager->collectFromFiles();
foreach ($translationFiles as $fileName => $languages) {
foreach ($languages as $languageKey => $path) {
$fileContent = $this->manager->getFileContent($path);
if (isset($allKeysInFiles[$fileName])) {
$missingKeys = array_diff($allKeysInFiles[$fileName], array_keys(array_dot($fileContent)));
foreach ($missingKeys as $i => $missingKey) {
if (Arr::has($fileContent, $missingKey)) {
unset($missingKeys[$i]);
}
}
$this->fillMissingKeys($fileName, $missingKeys, $languageKey);
}
}
}
}
示例8: condition
public function condition($inputs)
{
if (!Arr::has($inputs, $this->column)) {
return null;
}
$this->value = Arr::get($inputs, $this->column);
$value = array_filter($this->value, function ($val) {
return $val !== '';
});
if (empty($value)) {
return null;
}
if (!isset($value['start'])) {
return $this->buildCondition($this->column, '<=', $value['end']);
}
if (!isset($value['end'])) {
return $this->buildCondition($this->column, '>=', $value['start']);
}
$this->query = 'whereBetween';
return $this->buildCondition($this->column, $this->value);
}
示例9: get
/**
* Get the specified option value.
*
* @param string $key
* @param mixed $default
* @param bool $bool convert '0', '1' to bool value
* @return mixed
*/
public function get($key, $default = null, $bool = true)
{
if (!$this->has($key) && Arr::has(config('options'), $key)) {
$this->set($key, config("options.{$key}"));
}
$value = Arr::get($this->items, $key, $default);
if (!$bool) {
return $value;
}
switch (strtolower($value)) {
case 'true':
case '1':
return true;
case 'false':
case '0':
return false;
case 'null':
case '(null)':
return;
default:
return $value;
break;
}
}
示例10: getDataByColumn
/**
* @param array $data
* @param string|array $columns
* @return array|mixed
*/
protected static function getDataByColumn($data, $columns)
{
if (is_string($columns)) {
return Arr::get($data, $columns);
}
if (is_array($columns)) {
$value = [];
foreach ($columns as $name => $column) {
if (!Arr::has($data, $column)) {
continue;
}
$value[$name] = Arr::get($data, $column);
}
return $value;
}
}
示例11: hasAttribute
/**
* Returns true / false if the specified attribute
* exists in the attributes array.
*
* @param int|string $key
* @param int|string $subKey
*
* @return bool
*/
public function hasAttribute($key, $subKey = null)
{
if (is_null($subKey)) {
return Arr::has($this->attributes, $key);
}
return Arr::has($this->attributes, "{$key}.{$subKey}");
}
示例12: storeExpression
/**
* Save the expression
*
* @param string $key
* @param mixed $expression
* @return void
*/
protected function storeExpression($key, $expression)
{
if (A::has($this->expressions, $key)) {
$this->expressions = A::set($this->expressions, $key, $expression);
} else {
$this->expressions = A::add($this->expressions, $key, $expression);
}
$this->reload();
}
示例13: has
/**
* check if index already exists
*
* @param null $index
* @return bool
*/
public function has($index = null)
{
return Arr::has($this->data, $index);
}
示例14: has
/**
* Check if a configuration setting exists
*
* @param string $key
* @return boolean
*/
public function has($key)
{
return $this->arrHelper->has($this->data, $key);
}
示例15: offsetExists
/**
* Determine if an item exists at an offset.
*
* @param mixed $key
* @return bool
*/
public function offsetExists($key)
{
return Arr::has($this->convert(), $key);
}