如何在laravel5.1中实现一对多的关系

时间:2016-02-19 10:29:02

标签: php eloquent laravel-5.1

我有一张桌子

var arr = jQuery('#change_entry tr:gt(0)').map(function () {
    return [jQuery('input', this).map(function () {
        if (this.type != "checkbox" || this.checked) //added this line
            return this.value;
    }).get()];
}).get();

现在,排行榜的模型如下

Leadsheet

---leadcode

Deal

-- leadcode(foreign key)

我想只获得那些在交易表中使用Eloquent

的交易

谢谢

1 个答案:

答案 0 :(得分:0)

为了坚持使用约定,你应该大概Leadsheet并使用小写public function deal()。 在查询方面只能通过交易获得排行榜。

$leadsheets = Leadsheet::has('deal')->get();