I'm slightly confused and need a bit of guidance if someone wouldn't mind.
Just a bit of background, my application is a website containing a simple survey (a list of questions with possible responses retrieved from the database) Thus far, I have created the models for the questions and responses tables and have defined the relationships within these classes - ie, a question can have multiple possible responses whereas a response belongs to one question. I've used Eloquent to handle the retrieval of the data which works fine.
Now, I need to run a query using the query builder to retrieve the posted data because of some complex left joins that I cannot do using Eloquent, but I'm uncertain where to put these - do I put the query inside of a new model, or run it from my controller like I have when using Eloquent?
该代码应该包含在模型的方法中。所以如果你需要为用户做一个疯狂的连接..它将是$user->getSomeCrazyJoinedData()
...如果你想要你也可以使用查询范围将参数传递给它。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.