1 year ago

Using app.balde(Dynamic) in Other Controllers

Posted 1 year ago by pingzeeshan


I am new to laravel. I am working on a Ecommerce website. On the fronetend I have created a blade which uses HomeController.php. I need dynamic Header, footer and left menu so I fetched the data in __Constructor. Here is the code:

public function __construct() {

    $this->header_category_list = Category::where('is_header', 1)->where('is_enable', 1)->select('category_title', 'category_id')->get();

    $this->banner_list = Banner::all();
    $this->footer_category_list = Category::where('is_footer', 1)->where('is_enable', 1)->select('category_title', 'category_id')->get();
    $this->footer_page_list = Page::where('is_footer', 1)->select('page_title', 'page_id')->get();


Now I have another view category.list.balde using CategoryController in which extends blade.

My Question is do I need to call this arrays everytime in __Consturctor of CategoryController and all other Controllers?

Kindly Help.

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