ComposerServiceProvider.php 1.31 KB
<?php

namespace App\Providers;

use App\Models\Area;
use App\Models\Contact;
use App\Models\format_area;
use App\Models\Tag;
use App\Models\type_area;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;

class ComposerServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        $views = ['part.filter.main','part.filter.catalog', 'part.filter.category', 'part.filter.mapsobj'];

        View::composer($views,
            function($view) {
               $items_type_area = type_area::all();
               $items_format_area = format_area::all();
               $items_area = Area::all();
               $view->with([
                            'items_area' => $items_area,
                            'items_type_area' => $items_type_area,
                            'items_format_area' => $items_format_area,
                   ]);
            }
        );

        $views = ['layout.site', 'index', 'about', 'house.post', 'catalog', 'category_catalog'];
        View::composer($views, function($view) {
            $view->with(['items_contact' => Contact::limit(1)->get()]);
        });


    }

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }
}