Hello everyone i have a question about Eloquent Builder in Laravel
$query = EntryUserVote::query()
->join('users', 'challenge_entry.user_id', '=', 'users.id')
->groupBy(['user_id'])
->select([
'users.id as user_id',
'users.name as username',
DB::raw('count(*) AS amount'),
DB::raw("@row := @row + 1 as position")
])
->orderBy('amount', 'desc');
I have that Query in my repo and i need to basically add a "rank" which is what that position variable refers to, but i need to know how to initialize the variable in Eloquent. Doesn't make sense to do a from call since i'm already defining the table through the Eloquent Model...
How would you guys do this? A seperate SET statement?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zXFQkG
via IFTTT
Aucun commentaire:
Enregistrer un commentaire