我在我的應用程序中使用Laravel 5.1。我的MySQL查詢是將一個Mysql查詢轉換成Laravel 5雄辯?
"Select * from "
. "(Select u.* from "
. "("
. "SELECT u2.id as user_id, u2.fname as fname, u2.lname as lname, u2.uname as uname, u2.email as email, u2.address as address, u2.city_id as city_id, u2.website as website FROM users u1, users u2 where u1.city_id = u2.city_id && u1.id = '$this->current_user_id')
u left join follows f on u.user_id = f.following_id where f.following_id is null
UNION
Select uu.id as user_id, uu.fname as fname, uu.lname as lname, uu.uname as uname, uu.email as email, uu.address as address, uu.city_id as city_id, uu.website as website from users uu where uu.id in (Select u.user_id from (SELECT user_id FROM reviews group by user_id order by count(user_id) desc5
) u left join follows f on u.user_id=f.following_id where f.following_id is null
)
)
T LIMIT 5"
如何將它轉換成Laravel雄辯?
你試過轉換它嗎? –
desc5 ??什麼是 – Strawberry
Eloquent是一個ORM。因此,您需要[創建適當的模型](https://laravel.com/docs/5.1/eloquent#defining-models)和[關係](https://laravel.com/docs/5.1/eloquent-relationships #定義-關係)。 – Johnny