Laravel 5 拉威尔关系与3表使用雄辩?

Laravel 5 拉威尔关系与3表使用雄辩?,laravel-5,Laravel 5,我想使用multiple hasMany and belongs来表示命题使用两个函数,一个用于返回注释,另一个用于返回操作 如何从Action::with('proposition')检索数据注释 模型命题 public function proposition() { return $this- >belongsTo('App\Proposition','proposition_num_proposition'); }

我想使用multiple hasMany and belongs来表示命题使用两个函数,一个用于返回注释,另一个用于返回操作 如何从Action::with('proposition')检索数据注释

模型命题

      public function proposition()
     {
      return $this-
           >belongsTo('App\Proposition','proposition_num_proposition');
     }
示范作用

       public function action() {

    return $this->hasMany('App\Action','proposition_num_proposition');
      }
范本

     public function notes(){
    return $this->hasMany('App\Note','proposition_num_proposition');
    }
和桌子

提议 num_命题 提议

      public function proposition()
     {
      return $this-
           >belongsTo('App\Proposition','proposition_num_proposition');
     }
行动 身份证行动 行动 位置数命题

      public function proposition()
     {
      return $this-
           >belongsTo('App\Proposition','proposition_num_proposition');
     }
注 身份证 笔记 命题数量命题

      public function proposition()
     {
      return $this-
           >belongsTo('App\Proposition','proposition_num_proposition');
     }
内部控制器

   $actions = Action::all();
   $propositions = Proposition::with('actions');
    $notes = Note::all();
    $propositions2 = Proposition::with('notes');
鉴于

我想从命题中检索数据,其中(note.proposition\u num\u proposition=action.proposition\u num\u proposition) 使用laravel Elequot


有什么帮助吗?

你试过这样使用它吗

$actions = Action::with(['proposition', notes])->get();
或者你也可以看看laravel文档中的急切加载


如果您使用数组作为输入,则with应该可以解决您的问题

我尝试过,但鉴于此$action->proposition->note->proposition\u num\u proposition不起作用,您可以使用dd($actions)将查询转储到model App/Actioncus中的未定义关系[notes],其应为:$propositions=propositions::with('action'))------------------------------------$propositions2=命题::带('notes');