daha önce de gündeme getirmiştim ama bu işlemi manuel yapmak istiyorum, o yüzden yeni başlık altında açtım kusura bakmayın .https://codepen.io/kwilber/pen/WENjjV buradaki angular scripti kullanmak istiyorum. kategoriler isminde bir veri tabanı tablom var,
id | parent_id | text | expanded | link
çıktı aldığımda $return $kategoriler=Kategoriler::all()
ekran çıktısı aşağıdaki gibi
[
{
"id": 1,
"parent_id": 0,
"text": "Arçelik",
"expanded": 0,
"link": "Markalar/"
},
{
"id": 2,
"parent_id": 0,
"text": "Vestel",
"expanded": 0,
"link": "Markalar/"
},
{
"id": 3,
"parent_id": 7,
"text": "Bosh",
"expanded": 0,
"link": "Markalar/"
},
{
"id": 4,
"parent_id": 2,
"text": "Vestel Alt",
"expanded": 0,
"link": "Markalar/"
},
{
"id": 5,
"parent_id": 4,
"text": "Vestel Alt 2",
"expanded": 0,
"link": "Markalar/"
},
{
"id": 6,
"parent_id": 1,
"text": "Arçelik Alt 1",
"expanded": 0,
"link": "Markalar/"
},
{
"id": 7,
"parent_id": 6,
"text": "Arçelik Alt 2",
"expanded": 0,
"link": "Markalar/"
}
]
Laraveldeki bu çıktıyı, linkte paylaşmış olduğum codepen üzerindeki script.js dosyasında $scope.data veri şekline dönüştürmek istiyorum yani nestable parent child yapısıyla çıktı almak istiyorum. formda daha önce bununla ilgili bir çok paylaşım oldu, baum var ve bir tanede megasmus üstadın kullandığı var, ama onların dışında manuel olarak yapmak istiyorum. yani her defasında hızlıca kullanabileceğim bir yapı olsun istiyorum. yujarudaki json çıktının script.js deki $scope.data tipi
[
{
"id": 1,
"text": "Deneme",
"expanded": true,
"link": "http://google.com",
"items": [
{
"id": 2,
"text": "tables & chairs",
"link": "http://google.com"
},
{
"id": 3,
"text": "sofas",
"link": "http://google.com"
},
{
"id": 4,
"text": "occasional furniture"
},
{
"id": 5,
"text": "children’s furniture"
},
{
"id": 6,
"text": "beds",
"expanded": false,
"items": [
{
"id": 42,
"text": "tables & chairs"
},
{
"id": 43,
"text": "sofas"
},
{
"id": 44,
"text": "occasional furniture"
},
{
"id": 45,
"text": "children’s furniture",
"items": [
{
"id": 52,
"text": "tables & chairs"
},
{
"id": 53,
"text": "sofas"
},
{
"id": 54,
"text": "occasional furniture"
},
{
"id": 55,
"text": "children’s furniture"
}
]
}
]
}
]
},
{
"id": 7,
"text": "Decor",
"expanded": true,
"items": [
{
"id": 8,
"text": "bed linen"
},
{
"id": 9,
"text": "throws"
},
{
"id": 10,
"text": "curtains & blinds"
},
{
"id": 11,
"text": "rugs"
},
{
"id": 12,
"text": "carpets"
}
]
},
{
"id": 13,
"text": "Storage",
"expanded": true,
"items": [
{
"id": 14,
"text": "wall shelving"
},
{
"id": 15,
"text": "kids storage"
},
{
"id": 16,
"text": "multimedia storage"
},
{
"id": 17,
"text": "floor shelving"
},
{
"id": 18,
"text": "toilet roll holders"
},
{
"id": 19,
"text": "storage jars"
},
{
"id": 20,
"text": "drawers"
},
{
"id": 21,
"text": "boxes",
"link": "http://google.com"
}
]
}
]
şeklindedir. çıktımı buna benzetmek istiyorum nasıl yapabilirim ?