function printTree($tree, $template){
$output='';
foreach($tree as $node){
$output .= str_replace(['%nodeName%', '%nodeParam1%'], [$node['nodeName'], $node['nodeParam1']]);
}
return $output;
}
echo printTree($tree, '<li class="%nodeParam1%">%nodeName%</li>');
echo printTree($tree, '<p class="%nodeParam1%">%nodeName%</p>');
echo printTree($tree, '<div class="%nodeParam1%">%nodeName%</div>');
table chats
table members{
chat_id,
user_id
}
function chats(){
retrun $this->belongsToMany(Chat::class, 'members');
}
А почему нужно именно двумя запросами а не одним?