If we have following structure, the id variable is not recognized in the js. what is wrong? I mean, how to use id variable in where condition in blade statement? Meawhile, the blade syntax works properly but I don't know how to pass it the id variable. It assumes the id variable equals to zero!!!
<body>
<div class='fake' id='test'>
</div>
<script>
$('.fake').hover(function() {
var id = this.id;
var content = "<ul>"+
"@foreach(DB::table('category')->where('parent_id', 'id')->get() as $childCat)"+
"<li>"+
"{{$childCat->name}}"+
"</li>"+
"@endforeach"+
"</ul>";
}, function() {
});
$('#'+id).append(content);
</script>
</body>