Support the ongoing development of Laravel.io →
Requests Blade
Last updated 1 year ago.
0

Maybe you could check about "Laravel View Composers" to do wath you want. Here's the link to the documentation : http://laravel.com/docs/responses#view-composers .

Last updated 1 year ago.
0

One thing I don't get, this might be more of a MVC related question: how is using composers different from using controllers? When should I use one or the other, since they do pretty much the same thing (processing code to be shown in the view)

Last updated 1 year ago.
0

A composer is a recurring task which is bound to a specific view, so if you want to display a menu that you have stored in a database or some links in a footer that you have also stored in a database and that no matter which page you're on, then you should use a view composer.

But, if you want to do something on a specific page with some logic behind (like form validation, storing data, etc...), then you have to use a controller.

I'm not sure if it's enough clear but you can check this video from Jeffrey Way about view composers : https://laracasts.com/lessons/view-composers .

Last updated 1 year ago.
0

Thanks man, this was of great help! I'm discovering laravel now and it's awesome

Last updated 1 year ago.
0

You're welcome :).

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

raphadko raphadko Joined 13 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.