I am trying to make a query in Laravel, which should select values based on date, pick_score and order by hour and also by some specific String values that I have in my data set. The query is below, but I get "Call to undefined method Illuminate\Database\Eloquent\Builder::transform()" and I am not sure what I am doing wrong.
$matches = Match::select()
->where('date', $date)
->where('pick_score', '<>', '0')
->orderBy('hour')
->transform(function ($match) {
if(
$match->competition_type == "ATP - SINGLES"
or
$match->competition_type == "WTA - SINGLES"
){
$match->competition_type = -1;
}else{
$match->competition_type = 'competition_type';
}
return $match;
})
->sortBy('competition_type');
Can anyone help me with this error?