<?php

namespace App\Http\View\Composers;

use Illuminate\View\View;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Auth;

class HeaderComposer
{
    /**
     * Bind data to the view.
     *
     * @param  \Illuminate\View\View  $view
     * @return void
     */
    public function compose(View $view)
    {
        // Language data
        $languages = [
            ['code' => 'de', 'name' => 'Deutsch', 'flagUrl' => asset('images/flags/de.svg')],
            ['code' => 'en', 'name' => 'English', 'flagUrl' => asset('images/flags/en.svg')],
        ];

        $currentCode = App::getLocale();
        $currentLang = collect($languages)->firstWhere('code', $currentCode) ?? $languages[0];

        // Role data
        $role = '';
        if (Auth::check()) {
            $role = trim(Auth::guard('admin')->user()->getUserRole());
        }

        $view->with('languages', $languages)
             ->with('currentLang', $currentLang)
             ->with('role', $role);
    }
} 