53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
use App\Enums\StaticPageType;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\News;
|
|
use App\Models\Product;
|
|
use App\Models\Range;
|
|
use App\Models\StaticPage;
|
|
|
|
class RangeController extends Controller
|
|
{
|
|
/**
|
|
* Display the homepage.
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function index(): \Illuminate\Contracts\View\View
|
|
{
|
|
$rangeModels = Range::query()->get();
|
|
$staticPageModel = StaticPage::query()->where('type', StaticPageType::ranges)->first();
|
|
|
|
return view('fo.pages.ranges.index', compact('rangeModels', 'staticPageModel'));
|
|
}
|
|
|
|
/**
|
|
* Show a specific resource.
|
|
*
|
|
* @param \App\Models\Range $range
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function show(Range $range): \Illuminate\Contracts\View\View
|
|
{
|
|
$rangeModels = Range::query()->whereNot('id', $range->id)->limit(2)->inRandomOrder()->get();
|
|
$productModels = Product::query()->where('range_id', $range->id)
|
|
->where('published', true)
|
|
->orderBy('order', 'asc')
|
|
->paginate(9);
|
|
$newsModels = News::query()
|
|
->where('published', true)
|
|
->orderBy('created_at', 'desc')
|
|
->limit(6)
|
|
->get();
|
|
|
|
return view('fo.pages.ranges.show', [
|
|
'rangeModel' => $range,
|
|
'rangeModels' => $rangeModels,
|
|
'productModels' => $productModels,
|
|
'newsModels' => $newsModels,
|
|
]);
|
|
}
|
|
}
|