A
A
Alexey Vinogradov2019-04-08 13:51:49
Laravel
Alexey Vinogradov, 2019-04-08 13:51:49

Nested laravel with?

The essence of the question is as follows: there are 3 tables boards, tasks, task_settings sequentially linked by key in the Boards model function

public function task()
    {
        return $this->hasMany('App\Task');
    }

in the controller I pull with
$board = Board::with('task')->where('user_id', 2)->whereHas('task')->get();

well, and accordingly I get the model I need with nesting
Board
      Task

But there is also a third task_settings table that I need to pull out and put in Task to get an array with such nesting
Board-
      Task-
           Task_settings.

Is it possible to organize this whole thing with standard laravel tools?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2019-04-08
@Vinstrok

with('task.taskSettings')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question