mercredi 2 janvier 2019

Best Practice for injecting too much data into view

I am using a PHP framework called laravel(It is an MVC based framework). I am developing a system and almost in every single method of an entity controller that renders a view, I pass a lot of required data to the view and my controller looks really messy.

$data['data1'] = ['some-data-here'];
$data['data2'] = ['some-data-here'];
$data['data3'] = ['some-data-here'];
.
.
.
$data['data12'] = ['some-data-here'];
$data['data13'] = ['some-data-here'];

view('page.article.index)->with($data);

Is there any Design Pattern or Best Practice that helps the code to look cleaner?

Aucun commentaire:

Enregistrer un commentaire