php - Laravel ORM Model Hierarchy? -


i want create one-to-many relationship 1 model.

exactly want build hierarchy of categories.

for have migration script creates foreign key / column category_id.

in database easy. create 1 category "cars". create category "audi" parent id linked id of "cars".

but when create function in orm model this:

public function category() {     return $this->belongs_to('category'); } 

then create infinite loop.

what doing wrong? maybe not possible?

thank your suggestions!

now got working orm functionality. works fine, view can handle it!

public function children() {     return $this->has_many('category','category_id'); }  public function parent() {     return $this->belongs_to('category','category_id'); } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -