41 lines
1,009 B
PHP
41 lines
1,009 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Fo;
|
|
|
|
use App\Enums\Ranges\PictoEnum;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Product;
|
|
use App\Models\Range;
|
|
|
|
class ProductController extends Controller
|
|
{
|
|
/**
|
|
* Products index
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function index()
|
|
{
|
|
$products = Product::all()->sortby('order')->reverse()->groupBy('range_id');
|
|
$poultries = Range::all();
|
|
return view('fo.pages.products.index', compact(['products', 'poultries']));
|
|
}
|
|
|
|
/**
|
|
* Product show
|
|
*
|
|
* @param mixed $id
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function show(mixed $id)
|
|
{
|
|
$product = Product::where('id', $id)->first();
|
|
if ($product == null) {
|
|
$product = Product::where('slug', $id)->first();
|
|
if ($product == null) {
|
|
abort(404);
|
|
}
|
|
}
|
|
return view('fo.pages.products.show', compact('product'));
|
|
}
|
|
}
|