array_key_first
laravel/framework
Supported Versions: PHP 7 >= 7.3.0, PHP 8
Gets the first key of an array
array_key_first
(array
$array
):
int
|
string
|
null
$query
=
$this
->
database
->
table
(
$table
);
$similarResults
=
$query
->
where
(
array_key_first
(
$this
->
data
),
$this
->
data
[
array_key_first
(
$this
->
data
)]
)->
limit
(
$this
->
show
)->
get
();
src/Illuminate/Testing/Constraints/HasInDatabase.php
$similarResults
=
$query
->
where
(
array_key_first
(
$this
->
data
),
$this
->
data
[
array_key_first
(
$this
->
data
)]
)->
limit
(
$this
->
show
)->
get
();
if (
$similarResults
->
isNotEmpty
()) {
src/Illuminate/Testing/Constraints/HasInDatabase.php
return
array_map
(
[
$this
,
'prepareRule'
],
$rule
,
array_fill
((int)
array_key_first
(
$rule
),
count
(
$rule
),
$attribute
)
);
}
src/Illuminate/Validation/ValidationRuleParser.php
{
$builder
=
m
::
mock
(
Builder
::class);
$key
=
array_key_first
(
$this
->
data
);
$value
=
$this
->
data
[
$key
];
$builder
->
shouldReceive
(
'where'
)->
with
(
$key
,
$value
)->
andReturnSelf
();
tests/Foundation/FoundationInteractsWithDatabaseTest.php