<?php

namespace App\Http\Controllers;

use App\Models\Banner;
use App\Models\Package;
use Illuminate\Http\Request;
use Session;

class HomeController extends Controller
{
    public function index()
    {
        // $packages = Package::getActiveCache('status');
        // return view('package::index', ['packages' => $packages]);
        $packages = Package::getActiveCache('status');
        $banners = Banner::getActiveCache();
        return view('client.pages.home', [
            'banners' => $banners,
            'packages' => $packages
        ]);
    }

    public function changeLanguage(Request $request)
    {
        $lang = $request->language;
        $language = config('app.locale');
        if ($lang == 'en') {
            $language = 'en';
        }
        if ($lang == 'vi') {
            $language = 'vi';
        }
        Session::put('language', $language);
        return redirect()->back();
    }
}
