1

I created 3 models are Exams, Questions and Answers. I use nested eager loading to load all questions and answers of specific exams.

My function is:

public function allBy($examId)
{
    return \Exam::with('questions.answers')->get();
}

It works in Laravel 5.1. Today, I upgrade my project to Laravel 5.2 by creating new project and move files to it. However, when running above function, it quit program suddenly. In client side's console window (Chrome), it displays error with status 500 (Internal Server Error).

I try to use "try...catch" but it does not go to catch. It still quit when do get() function. I don't know where is the problem.

I also try to make simple eager loading:

return \Exam::with('questions')->get();

It works in laravel 5.2.

vutaviva
  • 127
  • 2
  • 10
  • Check log file for information about what is causing the error – jedrzej.kurylo Jan 10 '16 at 16:24
  • In storage\logs\laravel.log, I don't see any information logged when issue happens. – vutaviva Jan 10 '16 at 16:31
  • Enable the debugging mode by going into `config/app.php`, and setting `'debug' => env('APP_DEBUG', true),`. Then show us the error that appears on the page. – Ahmad Baktash Hayeri Jan 10 '16 at 17:00
  • It displays: FatalErrorException in Container.php line 700: Maximum function nesting level of '100' reached, aborting! – vutaviva Jan 10 '16 at 17:14
  • FYI, when I deep debug into Laravel framework, I recognize it quits at answers() function in my Question Model. In this function, I have only one code row: return $this->hasMany('App\Models\Answer' which used to define eloquent relationship. – vutaviva Jan 10 '16 at 17:44
  • I try create new project again and add dependence alternately. It works (load nested eagger loading success) until I add DebugBar (barryvdh/laravel-debugbar ver 2.1). After I disable DebugBar, It work again. What do DebugBar make issue? – vutaviva Jan 11 '16 at 03:05
  • I make more test for finding reason. Test 1 with enable DebugBar and use middleware "web" and "auth", it does not work. Test 2 with enable DebugBar and use only middleware "web", it works. – vutaviva Jan 11 '16 at 04:14
  • I search error nesting level of '100' reached. Some one suggested change xdebug.max_nesting_level =200. I try to change. And it works. – vutaviva Jan 11 '16 at 10:19

0 Answers0