Passing data to views

Posted 2 years ago by ekrist1

Hi.

I´m new to Lavarel, so I wonder if this is the correct way to do this.

I have some statistics data which i would like to pass to several views. In my accountcontroller today, i have an array that fetch data from my customer table: $accounts = account::all();

I would like to output the number of accounts (customers) to several of my views by using:

Will it be the right way of doing this to move the $accounts = account::all(); to a view composer? https://scotch.io/tutorials/sharing-data-between-views-using-laravel-view-composers https://laracasts.com/series/laravel-5-fundamentals/episodes/4

Another question: If i´m going to add some business logic (i.e format or change some data in on of my array´s), will the right way of doing this using Service Providers?

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

Reply to

Use Markdown with GitHub-flavored code blocks.