Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Fixes Expression no longer implements Stringable #46395

Merged
merged 4 commits into from
Mar 8, 2023
Merged
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
11 changes: 11 additions & 0 deletions src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Closure;
use Exception;
use Illuminate\Contracts\Database\Eloquent\Builder as BuilderContract;
use Illuminate\Contracts\Database\Query\Expression;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Database\Concerns\BuildsQueries;
use Illuminate\Database\Eloquent\Concerns\QueriesRelationships;
Expand Down Expand Up @@ -647,6 +648,8 @@ public function sole($columns = ['*'])
public function value($column)
{
if ($result = $this->first([$column])) {
$column = $column instanceof Expression ? $column->getValue($this->getGrammar()) : $column;

return $result->{Str::afterLast($column, '.')};
}
}
Expand All @@ -662,6 +665,8 @@ public function value($column)
*/
public function soleValue($column)
{
$column = $column instanceof Expression ? $column->getValue($this->getGrammar()) : $column;

return $this->sole([$column])->{Str::afterLast($column, '.')};
}

Expand All @@ -675,6 +680,8 @@ public function soleValue($column)
*/
public function valueOrFail($column)
{
$column = $column instanceof Expression ? $column->getValue($this->getGrammar()) : $column;

return $this->firstOrFail([$column])->{Str::afterLast($column, '.')};
}

Expand Down Expand Up @@ -859,6 +866,8 @@ public function pluck($column, $key = null)
{
$results = $this->toBase()->pluck($column, $key);

$column = $column instanceof Expression ? $column->getValue($this->getGrammar()) : $column;

// If the model has a mutator for the requested column, we will spin through
// the results and mutate the values so that the mutated version of these
// columns are returned as you would expect from these Eloquent models.
Expand Down Expand Up @@ -1775,6 +1784,8 @@ public function setModel(Model $model)
*/
public function qualifyColumn($column)
{
$column = $column instanceof Expression ? $column->getValue($this->getGrammar()) : $column;

return $this->model->qualifyColumn($column);
}

Expand Down