Supported Versions: PHP 7 >= 7.3.0, PHP 8
Gets the first key of an array
<?php array_key_first(array $array): int|string|null
<?php $segment = match ($segment) {
'\*' => '*',
'\{first}' => '{first}',
'{first}' => array_key_first(is_array($target) ? $target : collect($target)->all()),
'\{last}' => '{last}',
'{last}' => array_key_last(is_array($target) ? $target : collect($target)->all()),
default => $segment,
<?php $query = $this->database->table($table);
$similarResults = $query->where(
array_key_first($this->data),
$this->data[array_key_first($this->data)]
)->select(array_keys($this->data))->limit($this->show)->get();
<?php $similarResults = $query->where(
array_key_first($this->data),
$this->data[array_key_first($this->data)]
)->select(array_keys($this->data))->limit($this->show)->get();
if ($similarResults->isNotEmpty()) {
<?php return array_map(
[$this, 'prepareRule'],
$rule,
array_fill((int) array_key_first($rule), count($rule), $attribute)
);
}
<?php {
$builder = m::mock(Builder::class);
$key = array_key_first($this->data);
$value = $this->data[$key];
$builder->shouldReceive('where')->with($key, $value)->andReturnSelf();