Files
eatvio-infra/app/Http/Controllers/RecipeController.php
Anatoliy Poloz 92a54106ef analysators added
2023-12-18 14:36:32 +03:00

61 lines
1.2 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Recipe;
class RecipeController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('recipe/index');
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('recipe/edit_form');
}
/**
* Display the specified resource.
*
* @return \Illuminate\Http\Response
*/
public function show(Recipe $recipe)
{
$data = [
'author' => $recipe->author()->first(),
'tags' => $recipe->tags()->get(),
'recipe' => $recipe,
];
$expiresAt = now()->addHours(24);
views($recipe)
->cooldown($expiresAt)
->record();
return view('recipe/show', $data);
}
/**
* Show the form for editing the specified resource.
*
* @return \Illuminate\Http\Response
*/
public function edit(Recipe $recipe)
{
return view('recipe/edit_form', ['recipe' => $recipe]);
}
}