We are currently using the Laravel framework for several projects, but one problem that we continue to work on, which I don't like, is the following problem:
Let's say you have a homepage and content page
Homepage The controller has all the PHP code on the main page. The ContentpageController has all the content specific php codes
we have app.blade.php which makes
@yield('page')
Homepage The Controller calls up the view.blade.php homepage containing
@extends('app') @section('page') Some HTML part @include('parts.top_5') @endsection
ContentController calls the content.blade.php view containing
@extends('app') @section('page') Some different HTML part @include('parts.top_5') @endsection
Here you can see that both pages include part.top_5, the top 5 needs some specific variables to display top5. Now the problem is that we are currently copying the code for the top5 variables in both the controllers and the group middleware, but is there a better solution for generating some specific click variables when this part is turned on? So a bit like starting a controller function when loading a blade template?
I searched the internet but didn't seem to find anyone with the same question. Hope someone can help me with this mental problem!
source share