I'm using Laravel
as an example.
In Controller
I do 2 searches.
public function index()
{
$page_title = "Relatório";
$projetos = Projetos::orderBy('alguma_coluna')->get();
$subprojetos = Subprojetos::get();
return view('pages.relatorio.index',
compact('page_title','projetos ','subprojetos ')
);
}
I need to do a treatment before printing this data in View
.
The code below is just an example of data processing
foreach($projetos AS $thisRow) {
$isDuplicate = false;
$projeto_nome = $thisRow["projeto_nome"];
$hasNewIcon = $thisRow["hasNewIcon"];
$img_src = $thisRow["img_src"];
if($hasNewIcon === "1"){
$hasNewIcon = "<img src='algumaimg.jpg'>";
} else {
$hasNewIcon = "";
}
foreach ($subprojetos AS $r) {
$subprojeto_nome = $r["subprojeto_nome"];
if($contador > 0){
$isDuplicate = true;
}
$contador++;
}
$html .= <<<HTML
<div class="col-lg-2 col-md-2 col-xs-6 thumb">
<img src="{$img_src}" class="img-responsive"/>
<div class="equal-height-panels">
<div class="row">
<h5 class="text-center">{$projeto_nome}</h5>
{$hasNewIcon}
</div>
</div>
</div>
HTML;
}
My question is: Should I do this treatment where? No Controller
, View
or Model
?