Im new in laravel
Always get this
Symfony\Component\ErrorHandler\Error\FatalError Allowed memory size of 2147483648 bytes exhausted (tried to allocate 2147483656 bytes) Error on this line
$arrayGejala = collect([
substr($gejala1, 14, 1),
substr($gejala2, 14, 1),
substr($gejala3, 14, 1),
])->implode(',');
$belief = DB::table('pengetahuan')->select(DB::raw("GROUP_CONCAT(penyakit.kode_penyakit)"), 'pengetahuan.bobot')
->from('pengetahuan')
->join('penyakit', 'pengetahuan.id_penyakit', '=', 'penyakit.id_penyakit')
->whereIn('pengetahuan.id_gejala', [(array)$arrayGejala[0],(array)$arrayGejala[2],(array)$arrayGejala[4]])
->groupBy('pengetahuan.id_gejala')
->get();
$evidence = array();
while ($row = $belief->first()) {
$evidence[]=$row;
}
while ($row = $belief->first())will result in an infinite loop. If$belief->first()is truthy once it will be truthy forever (the function is "pure" i.e. it doesn't change the state of the collection). You might want to do something like$evidence = $belief->all()instead of a loop