Akainu Lionheart Akainu Lionheart - 5 months ago 30
PHP Question

Make eloquent give only sql clause

I was trying to rip off every connection function of Laravel's eloquent to give me SQL clause without querying it with PDO ( I also cleaning off every PDO instances from the code) and make eloquent a standalone package. I just want it to give me sql clause without connect to any db when I use an eloquent model just like this :

Request : Users::with('group')->take(5)->get();
Response : Select * from users.....

Can this be done ?


use ->toSql() instead of ->get()