2023-04-03 10:47:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
2023-04-05 09:46:24 +00:00
|
|
|
namespace App\Http\Controllers\Fo;
|
2023-04-03 10:47:55 +00:00
|
|
|
|
2023-04-05 09:46:24 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Models\Product;
|
|
|
|
|
use App\Models\Range;
|
2023-05-04 16:00:15 +02:00
|
|
|
use Illuminate\Contracts\Database\Eloquent\Builder;
|
2023-04-03 10:47:55 +00:00
|
|
|
|
|
|
|
|
class ProductController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Products index
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
2023-05-04 16:00:15 +02:00
|
|
|
$ranges = Range::query()->where('status', true)
|
|
|
|
|
->whereHas('products', function (Builder $q) {
|
|
|
|
|
$q->where('status', true);
|
|
|
|
|
})->with('products', function (Builder $q) {
|
|
|
|
|
$q->where('status', true);
|
|
|
|
|
})->get();
|
|
|
|
|
return view('fo.pages.products.index', compact(['ranges']));
|
2023-04-03 10:47:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Product show
|
|
|
|
|
*
|
2023-05-04 16:00:15 +02:00
|
|
|
* @param \App\Models\Product $publishedProduct
|
2023-04-03 10:47:55 +00:00
|
|
|
* @return \Illuminate\Contracts\View\View
|
|
|
|
|
*/
|
2023-05-04 16:00:15 +02:00
|
|
|
public function show(Product $publishedProduct)
|
2023-04-03 10:47:55 +00:00
|
|
|
{
|
2023-05-04 16:00:15 +02:00
|
|
|
return view('fo.pages.products.show', ['productModel' => $publishedProduct]);
|
2023-04-03 10:47:55 +00:00
|
|
|
}
|
|
|
|
|
}
|