Support the ongoing development of Laravel.io →
posted 9 years ago
Eloquent

0

down vote

favorite

First Blade View - Works fine

{{Auth::user()->firstName}} {{Auth::user()->getAdminAccount()->level}}

Then I call to controller, there also dd(Auth::user()->getAdminAccount()->level) works fine

After that I redirect to same page, then I get Error

Maximum function nesting level of '100' reached, aborting!

13 C:\wamp\www\PayPanel\PayPanel\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php(207): Illuminate\Database\Eloquent\Builder->get()

14 C:\wamp\www\PayPanel\PayPanel\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php(220): Illuminate\Database\Eloquent\Builder->first()

15 C:\wamp\www\PayPanel\PayPanel\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Relations\Relation.php(344): Illuminate\Database\Eloquent\Builder->firstOrFail()

16 C:\wamp\www\PayPanel\PayPanel\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Relations\Relation.php(344): call_user_func_array:{C:\wamp\www\PayPanel\PayPanel\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Relations\Relation.php:344}()

17 C:\wamp\www\PayPanel\PayPanel\app\User.php(50): Illuminate\Database\Eloquent\Relations\Relation->__call()

18 C:\wamp\www\PayPanel\PayPanel\app\User.php(50): Illuminate\Database\Eloquent\Relations\HasMany->firstOrFail()

19 C:\wamp\www\PayPanel\PayPanel\storage\framework\views\13e1e8769f3412635d77f8349fdd960f4b7381b8.php(278): App\User->getAdminAccount()

My function in user Model public function commission() { return $this->hasMany('App\Commission', 'userId', 'id'); }

public function getAdminAccount() { return $this->commission()->where('level','A')->firstOrFail(); }

Last updated 3 years ago.
0

Increase the value of xdebug.max_nesting_level in your php.ini:

xdebug.max_nesting_level = 1000
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.