How to create self referential relationship in laravel?

前端 未结 4 868
臣服心动
臣服心动 2020-12-02 18:03

I am new to Laravel. I Just want to create a self referential model. For example, I want to create a product category in which the field parent_id as same as pr

4条回答
  •  不思量自难忘°
    2020-12-02 19:04

    Your model is not at fault for producing the "maximum function nesting level of '100' reached" error. It's XDebug's configuration; increase your xdebug.max_nesting_level.

    The following is from a 2015 post by @sitesense on laracasts.com:

    This is not a bug in Laravel, Symfony or anything else. It only occurs when XDebug is installed.

    It happens simply because 100 or more functions are called recursively. This is not a high figure as such and later versions of XDebug (>= 2.3.0) have raised this limit to 256. See here:

    http://bugs.xdebug.org/bug_view_page.php?bug_id=00001100

    EDIT: In fact the latest Homestead provisioning script already sets the limit to 250. See line 122 here:

    https://github.com/laravel/settler/blob/master/scripts/provision.sh#L122

    So the addition of xdebug.max_nesting_level = 250 to php.ini should do it.

提交回复
热议问题