Question about a dashboard controller

Posted 2 years ago by TutanRamon

I've a couple of years PHP experience (spaghetti style ;-)). At the moment I am building my first MVC application using Laravel.

I am writing a dashboard page with lots of different kind of information, ie "Amount of visitors", "Amount of sold products", "catalogue size", "newest product" etc. etc. Back in the 'old days', I usually had a functions.php with all kinds of functions to retrieve this information. Then, I called these functions from the actual dashboard page template. I know, that's not the nicest way and a horror for other developers. That's one of the reasons why I wanted to go for Laravel.

I defined the template, the basic controllers and models for Product, Transaction, Visitor etc. But now I am kinda stuck. What's the best practice for sending all this data to the view? After reading on the web I concluded I have two possibilities:

  • Writing a dashboard controller with all kind of methods to retrieve the data needed
  • Making use of a facade which retrieves the data for me (from all the other controllers) and sends one(??) object with all the info to the view

Is one of the above the right approach for my 'challenge'?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.