Reputation: 409
I have Folder
model, and the problem is, that I want to have Folder
inside another Folder
, what relationship can I use in this situation? I thought of adding one more column to Folder model, something like "parentFolderId", is it correct solution in this situation?
Upvotes: 1
Views: 37
Reputation: 15296
Table folder
* id
* name
* parent_folder_id
Now in the folder model, you can make a hasMany Relation. cause one folder has many folders.
function folders(){
return $this->hasMany('App\Folder','parent_folder_id','id');
}
Upvotes: 4