Files
soorya-carpet/app/Http/Controllers/Client/HomeController.php
admin 48e089d3c8
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
feat: FAQ controller made
2025-10-27 15:18:31 +05:45

95 lines
2.7 KiB
PHP

<?php
namespace App\Http\Controllers\Client;
use App\Http\Controllers\Controller;
use App\Models\Carousel;
use App\Models\Faq;
use App\Models\Product;
use App\Models\Testimonial;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Storage;
class HomeController extends Controller
{
public function home()
{
$carousel = Carousel::all();
$testimonail = Testimonial::all();
$response = [
"carousel" => $carousel->map(function ($item) {
return [
"alt" => $item->alt,
"image_url" => $item->image_url ? asset(Storage::url($item->image_url)) : null,
];
}),
"testimonial" => $testimonail->map(function ($item) {
return [
"name" => $item->name,
"location" => $item->location,
"image" => $item->image ? asset(Storage::url($item->image)) : null,
"description" => $item->description
];
})
];
return Inertia::render('welcome', ['data' => $response]);
}
public function product()
{
$product = Product::all();
$productResponse = $product->map(function ($item) {
return [
"id" => $item->id,
"title" => $item->title,
"type" => $item->type,
"image_url" => $item->image_url ? asset(Storage::url($item->image_url)) : null,
];
});
return Inertia::render('product', ['product' => $productResponse]);
}
public function art()
{
return Inertia::render('art');
}
public function bespoke()
{
$product = Product::where("type", "bespoke")->get();
$productResponse = $product->map(function ($item) {
return [
"id" => $item->id,
"title" => $item->title,
"type" => $item->type,
"image_url" => $item->image_url ? asset(Storage::url($item->image_url)) : null,
];
})->values();
return Inertia::render("bespoke", ["product" => $productResponse]);
}
public function gallery()
{
return Inertia::render("gallery");
}
public function contact()
{
return Inertia::render('contact');
}
public function faq()
{
$faq = FAQ::all();
$faqResponse = $faq->map(function ($item) {
return [
"id" => $item->id,
"question" => $item->question,
"answer" => $item->answer,
];
});
return Inertia::render('faq', ['faq' => $faqResponse]);
}
}