<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Http;
use App\Models\Property;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
       View::composer('*', function ($view) {
        $categories = Property::select('category_name')
            ->distinct()
            ->pluck('category_name')
            ->filter() // remove null values
            ->map(fn($cat) => strtolower($cat))
            ->toArray();

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