Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public function scalar($query, $bindings = [], $useReadPdo = true)
throw new MultipleColumnsSelectedException;
}

return array_last($record);
return array_first($record);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function setForeignAttributesForCreate(Model $model)
*/
public function upsert(array $values, $uniqueBy, $update = null)
{
if (! empty($values) && ! is_array(array_last($values))) {
if (! empty($values) && ! is_array(array_first($values))) {
$values = [$values];
}

Expand Down
10 changes: 5 additions & 5 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3158,7 +3158,7 @@ public function soleValue($column)
{
$result = (array) $this->sole([$column]);

return array_last($result);
return array_first($result);
}

/**
Expand Down Expand Up @@ -3781,7 +3781,7 @@ public function insert(array $values)
return true;
}

if (! is_array(array_last($values))) {
if (! is_array(array_first($values))) {
$values = [$values];
}

Expand Down Expand Up @@ -3818,7 +3818,7 @@ public function insertOrIgnore(array $values)
return 0;
}

if (! is_array(array_last($values))) {
if (! is_array(array_first($values))) {
$values = [$values];
} else {
foreach ($values as $key => $value) {
Expand Down Expand Up @@ -3976,7 +3976,7 @@ public function upsert(array $values, array|string $uniqueBy, ?array $update = n
return (int) $this->insert($values);
}

if (! is_array(array_last($values))) {
if (! is_array(array_first($values))) {
$values = [$values];
} else {
foreach ($values as $key => $value) {
Expand All @@ -3987,7 +3987,7 @@ public function upsert(array $values, array|string $uniqueBy, ?array $update = n
}

if (is_null($update)) {
$update = array_keys(array_last($values));
$update = array_keys(array_first($values));
}

$this->applyBeforeQueryCallbacks();
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Query/Grammars/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1186,11 +1186,11 @@ public function compileInsert(Builder $query, array $values)
return "insert into {$table} default values";
}

if (! is_array(array_last($values))) {
if (! is_array(array_first($values))) {
$values = [$values];
}

$columns = $this->columnize(array_keys(array_last($values)));
$columns = $this->columnize(array_keys(array_first($values)));

// We need to build a list of parameter place-holders of values that are bound
// to the query. Each insert should have the exact same number of parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ protected function compileUpdateWithJoins(Builder $query, $table, $columns, $whe
*/
public function compileUpsert(Builder $query, array $values, array $uniqueBy, array $update)
{
$columns = $this->columnize(array_keys(array_last($values)));
$columns = $this->columnize(array_keys(array_first($values)));

$sql = 'merge '.$this->wrapTable($query->from).' ';

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Schema/Grammars/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ protected function getCommandByName(Blueprint $blueprint, $name)
$commands = $this->getCommandsByName($blueprint, $name);

if (count($commands) > 0) {
return array_last($commands);
return array_first($commands);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Fluent.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public function __call($method, $parameters)
return $this->macroCall($method, $parameters);
}

$this->attributes[$method] = count($parameters) > 0 ? array_last($parameters) : true;
$this->attributes[$method] = count($parameters) > 0 ? array_first($parameters) : true;

return $this;
}
Expand Down