当前位置: 首页>>代码示例>>PHP>>正文


PHP Arr::isAssoc方法代码示例

本文整理汇总了PHP中Illuminate\Support\Arr::isAssoc方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::isAssoc方法的具体用法?PHP Arr::isAssoc怎么用?PHP Arr::isAssoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Arr的用法示例。


在下文中一共展示了Arr::isAssoc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: instanceFromRequest

 /**
  * Create instance from reques
  *
  * @param  string $method
  * @param  null|int|string $id
  * @param  array|\Illuminate\Contracts\Support\Arrayable $params
  * @return $this|array
  */
 protected static function instanceFromRequest($method, $id = null, $params = [])
 {
     $response = static::requestToArray($method, $id, $params);
     if (Arr::isAssoc($response)) {
         return new static($response);
     }
     return Collection::makeOf(static::class, $response);
 }
开发者ID:loduis,项目名称:alegra-php,代码行数:16,代码来源:Resource.php

示例2: getPostgisFields

 public function getPostgisFields()
 {
     if (property_exists($this, 'postgisFields')) {
         return Arr::isAssoc($this->postgisFields) ? array_keys($this->postgisFields) : $this->postgisFields;
         //Returns the non-associative array that doesn't define the geometry type.
     } else {
         throw new PostgisFieldsNotDefinedException(__CLASS__ . ' has to define $postgisFields');
     }
 }
开发者ID:kyestork,项目名称:laravel-postgis,代码行数:9,代码来源:PostgisTrait.php

示例3: buildMorphMapFromModels

 /**
  * Builds a table-keyed array from model class names.
  *
  * @param  string[]|null $models
  * @return array|null
  */
 protected static function buildMorphMapFromModels(array $models = null)
 {
     if (is_null($models) || Arr::isAssoc($models)) {
         return $models;
     }
     $tables = array_map(function ($model) {
         return (new $model())->getEndpoint();
     }, $models);
     return array_combine($tables, $models);
 }
开发者ID:ashleigh-hopkins,项目名称:rest-model,代码行数:16,代码来源:Relation.php

示例4: setRows

 public function setRows($rows = [])
 {
     if (Arr::isAssoc($rows)) {
         foreach ($rows as $key => $item) {
             $this->rows[] = [$key, $item];
         }
         return $this;
     }
     $this->rows = $rows;
     return $this;
 }
开发者ID:z-song,项目名称:laravel-admin,代码行数:11,代码来源:Table.php

示例5: getFillable

 /**
  * Get the fillable attributes for the model.
  *
  * @return array
  */
 public function getFillable()
 {
     if ($fillable = $this->fillable) {
         if (Arr::isAssoc($fillable)) {
             return $fillable;
         }
         $keys = array_values($fillable);
         $types = array_fill(0, count($keys), 'string');
         return array_combine($keys, $types);
     }
 }
开发者ID:loduis,项目名称:alegra-php,代码行数:16,代码来源:AttributeFillable.php

示例6: macroSendHandler

 /**
  * Send email the handler method
  *
  * @param  int|static $resource
  * @param  array $options
  * @return bool
  */
 protected static function macroSendHandler($resource, ...$options)
 {
     if (static::isResource($resource)) {
         $resource = $resource->id;
     }
     if ($isAssoc = count($options) == 1 && Arr::isAssoc($options[0])) {
         $options = $options[0];
     }
     if (!$isAssoc) {
         $options = ['emails' => $options];
     }
     $response = static::request('POST', $resource . '/email', $options);
     return $response->getStatusCode() === 200;
 }
开发者ID:loduis,项目名称:alegra-php,代码行数:21,代码来源:Mailable.php

示例7: add

 public function add($label, $data = [], $fillColor = '')
 {
     if (is_array($label)) {
         if (Arr::isAssoc($label)) {
             $this->data[] = $label;
         } else {
             foreach ($label as $item) {
                 call_user_func_array([$this, 'add'], $item);
             }
         }
         return $this;
     }
     $this->data['datasets'][] = ['label' => $label, 'data' => $data, 'fillColor' => $fillColor];
     return $this;
 }
开发者ID:z-song,项目名称:laravel-admin,代码行数:15,代码来源:Bar.php

示例8: prepareArrayLines

 /**
  * Prepare array elements for formatting.
  *
  * @param array $array
  * @return array
  */
 protected static function prepareArrayLines(array $array)
 {
     $isAssoc = Arr::isAssoc($array);
     array_walk($array, function (&$value, $index, $withIndexes = false) {
         if (is_array($value)) {
             $value = self::formatArray($value);
         } else {
             $value = self::formatScalar($value);
         }
         if ($withIndexes) {
             $value = self::formatScalar($index) . ' => ' . $value;
         }
     }, $isAssoc);
     return $array;
 }
开发者ID:constant-null,项目名称:backstubber,代码行数:21,代码来源:Formatter.php

示例9: add

 public function add($label, $value = '', $color = '', $highlight = '')
 {
     if (is_array($label)) {
         if (Arr::isAssoc($label)) {
             $this->data[] = $label;
         } else {
             foreach ($label as $item) {
                 call_user_func_array([$this, 'add'], $item);
             }
         }
         return $this;
     }
     $this->data[] = ['label' => $label, 'value' => $value, 'color' => $color, 'highlight' => $highlight];
     return $this;
 }
开发者ID:z-song,项目名称:laravel-admin,代码行数:15,代码来源:Pie.php

示例10: prepareInsert

 /**
  * Prepare input data for insert.
  *
  * @param $inserts
  * @return array
  */
 public function prepareInsert($inserts)
 {
     $first = current($inserts);
     if (is_array($first) && Arr::isAssoc($first)) {
         $inserts = Arr::dot($inserts);
     }
     foreach ($inserts as $column => $value) {
         if (is_null($field = $this->getFieldByColumn($column))) {
             unset($inserts[$column]);
             continue;
         }
         if (method_exists($field, 'prepare')) {
             $inserts[$column] = $field->prepare($value);
         }
     }
     $prepared = [];
     foreach ($inserts as $key => $value) {
         Arr::set($prepared, $key, $value);
     }
     return $prepared;
 }
开发者ID:barryzhang,项目名称:laravel-admin,代码行数:27,代码来源:Form.php

示例11: isValidValue

 /**
  * Validate the value as safe for this object
  *
  * @param  mixed  $value the value to test
  * @return boolean
  */
 private function isValidValue($value)
 {
     return is_scalar($value) || is_array($value) && !$this->arrHelper->isAssoc($value) && count($value) === count(array_filter($value, 'is_scalar'));
 }
开发者ID:benrowe,项目名称:laravel-config,代码行数:10,代码来源:Config.php

示例12: processRelationship

 /**
  * Process model relationship
  *
  * @param array $data
  * @param array $relationships
  * @param string $relationshipMethod
  * @return void
  */
 protected function processRelationship(&$data, $relationships, $relationshipMethod)
 {
     if (!isset($data['relationship'])) {
         $data['relationship'] = [];
     }
     $relationships = Arr::isAssoc($relationships) ? [$relationships] : $relationships;
     foreach ($relationships as $relationship) {
         $method = $relationshipMethod . 'Relationship';
         $data['relationship'][] = $this->grammar->{$method}($relationship);
     }
 }
开发者ID:bebnev,项目名称:laravel-schema-parser,代码行数:19,代码来源:Processor.php

示例13: structureMatches

 /**
  * Structure the matches array.
  *
  * @param  \Phroggyy\Discover\Contracts\Searchable $model
  * @param  array $query
  * @return array|string
  */
 private function structureMatches(Searchable $model, $query)
 {
     // If the query is an array of arrays, we assume the
     // developer knows exactly what they're doing and
     // are providing a complete match query for us.
     if (is_array($query) && !Arr::isAssoc($query)) {
         return $query;
     }
     $key = '';
     // If the search index turns out to actually be nested, we
     // want to make sure we use the name of the subdocument
     // when such a query is performed. This is necessary.
     if ($this->indexIsNested($model->getSearchIndex())) {
         $key = $this->retrieveNestedIndex($model->getSearchIndex())[1] . '.';
     }
     // If the query is just a string, we assume the user
     // intends to just do a simple match query on the
     // default search field defined in their model.
     if (is_string($query)) {
         return [['match' => [$key . $model->getDefaultSearchField() => $query]]];
     }
     $query = Collection::make($query);
     return $query->map(function ($constraint, $property) use($key) {
         if (strpos($property, '.') === false) {
             $property = $key . $property;
         }
         return ['match' => [$property => $constraint]];
     })->values()->all();
 }
开发者ID:phroggyy,项目名称:discover,代码行数:36,代码来源:ElasticSearchService.php

示例14: normalizeAclPresence

 /**
  * Normalizes ACL presence data to an array of ACLPresence instances.
  *
  * @param $data
  * @return AclPresenceInterface[]
  */
 protected function normalizeAclPresence($data)
 {
     if ($data instanceof AclPresenceInterface) {
         $data = [$data];
     } elseif (is_array($data) && !Arr::isAssoc($data)) {
         $presences = [];
         foreach ($data as $nestedData) {
             $presences[] = new AclPresence($nestedData);
         }
         $data = $presences;
     } else {
         $data = [new AclPresence($data)];
     }
     /** @var AclPresenceInterface[] $data */
     // Now normalized to an array with one or more ACL presences.
     // Make sure the permission children are listed as simple strings.
     foreach ($data as $index => $presence) {
         $children = $presence->permissions() ?: [];
         if ($children instanceof Arrayable) {
             $children = $children->toArray();
         }
         if (!is_array($children)) {
             $children = [$children];
         }
         $data[$index]->setPermissions($children);
     }
     return $data;
 }
开发者ID:czim,项目名称:laravel-cms-core,代码行数:34,代码来源:AclRepository.php

示例15: getCastFromFillable

 /**
  * Get casts from fillable attribute
  * When fillable is assoc the value is the type
  *
  * @return array
  */
 protected function getCastFromFillable()
 {
     $fillable = $this->fillable;
     if (Arr::isAssoc($fillable)) {
         return $fillable;
     }
     return [];
 }
开发者ID:loduis,项目名称:alegra-php,代码行数:14,代码来源:AttributeCastable.php


注:本文中的Illuminate\Support\Arr::isAssoc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。