Telescope caching 55 files where it should cache 1

Posted 4 weeks ago by nhayder

Just installed telescope on my app.

On my app, i have 4 view composers that will provide a certain data across the entire website. (Theme, Copyright msg, btns data)

// my view composer looks like this

        View::composer('*', function ($view) {
            
            $view->with('btns', Navigation::getNavigationBtns());

        });

        View::composer('*', function ($view) {
            
            $view->with('navbar', Topmenu::getTopMenu());

        });

        View::composer('*', function ($view) {
            
            $view->with('copyright', Copyright::getCopyRights());

        });

        View::composer('*', function ($view) {
            
            $view->with('theme', Theme::getTheme());

        });

these are snippets of individual models

// theme model
    public static function getTheme()
    {
    
        $theme = Cache::rememberForever('theme', function () {

            return static::findOrFail(1);
            
        });
        
        return $theme;
    }


// copyright model
    public static function getCopyRights()
    {

        $copyright = Cache::rememberForever('copyright', function () {

            return static::findOrFail(1);
            
        });

        return $copyright;

    }

// topmenu navigation 

    public static function getTopMenu()
    {
    
        $navbar = Cache::rememberForever('navbar', function () {
        
            return Topmenu::findOrFail(1);
            
        });

        return $navbar;
        
    }

// navigation

    public static function getNavigationBtns()
    {
    
        $btns = Cache::rememberForever('btns', function () {
        
            return Navigation::with('submenu', 'nav_btn_linked_page', 'nav_btn_linked_article')->get();
        });

        return $btns;

    }

keeping in maind that my home page is totally empty except of the cached data above? But yet? i can see from telescope that laravel is hitting these 4 files 55 time, where i was expecting it to hit them only one time, I'm not sure where did i go wrong.

any ideas ???

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