38 lines
905 B
PHP
38 lines
905 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Product;
|
|
|
|
class ProductController extends Controller
|
|
{
|
|
/**
|
|
* Products index
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function index()
|
|
{
|
|
$products = Product::all()->sortby('sequence')->reverse()->groupBy('poultry');
|
|
$poultries = $products->keys()->sort();
|
|
return view('pages.produkte', 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('pages.produkt', compact('product'));
|
|
}
|
|
}
|