forked from eatvio/eatvio-infra
61 lines
1.2 KiB
PHP
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]);
|
|
}
|
|
}
|