0
Wie zu tun, Multi-Level-Selbst beitreten in Laravel 5.4
Ich habe Tabelle wie folgt.Laravel Eloquent Multi Level Selbst Join
ID name ParentId
1 abc 0
2 acd 1
3 ads 1
4 xyz 2
5 xxy 2
6 plm 3
7 ytr 4
8 lks 6
Jetzt brauche ich:
# if i id 1 Aufruf wird es voll Baum unter ihm zurückzukehren.
# wenn ich es leer nennen es ich voll Baum
# return this
public function getParent() {
return $this->belongsTo(self::class, 'ParentId','id');
}
public function getChild(){
return $this->hasMany(self::class, 'ParentId','id');
}
its me Einzel Brunch geben, aber ich brauche voll davon.
jemand eine PLZ Hilfe.
Endlich kann ich es tun. Ich habe das getChild in rekursiver Funktion aufgerufen. – Azad
wie Sie lösen, können Sie mir Ihren Code sehen? –