File: /home/richfield/public_html/app/Http/HomeController.php
<?php
namespace App\Http;
use App\Helpers\TranslationHelper;
use App\Http\Controllers\Controller;
use App\Http\Requests\ContactRequest;
use App\Models\{About, CategoryProduct, Contact, Gallery, Partner, Product, Slider};
class HomeController extends Controller
{
public function index()
{
$data = [
'abouts' => About::all(),
'productCategories'=>CategoryProduct::all(),
'products'=>Product::with('category')->get(),
'gallery' => Gallery::all(),
'sliders'=> Slider::all(),
'partners'=>Partner::all()
];
return view('index', $data);
}
public function contact(ContactRequest $request)
{
Contact::create($request->validated());
toastr()->success(TranslationHelper::translate('Message sent successfully'));
return back();
}
public function swap($locale)
{
app()->setLocale($locale);
\App::setLocale($locale);
session()->put('locale', $locale);
return redirect()->back();
}
}