Eagar loading,parent child relationship,Sub relationship in laravel

56

return $this->_planet->with(['alphabets' => function ($alphabets) {
            $alphabets->with(['tasks' => function ($task) {
                $task->with(['game' => function ($game) {
                    $game->with(['questions' => function ($questions) {
                        $questions->with(['choices' => fn ($choices) => $choices->select(["id", "answer_text", "is_correct", "audio_file", "question_id"])])->addSelect(["id", "question_text", "audio_name", "max_answer_selection", "game_id"]);
                    }])->addSelect(['id', 'name', "type", "identifier"]);
                }])->addSelect(['id', 'title', "type", "video_link", "alphabets_id", "game_id"]);
            }])->addSelect(['id', 'name', "identifier", "value", "planet_id"]);
        }])->addSelect(['id', 'name', "identifier", "image"])->where("id", 1)->get();

Comments

Submit
0 Comments