forked from eatvio/eatvio-infra
same at 22.05.2023
This commit is contained in:
63
app/Http/Controllers/RecipeController.php
Normal file
63
app/Http/Controllers/RecipeController.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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.
|
||||
*
|
||||
* @param \App\Models\Recipe $recipe
|
||||
* @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.
|
||||
*
|
||||
* @param \App\Models\Recipe $recipe
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Recipe $recipe)
|
||||
{
|
||||
return view('recipe/edit_form', ['recipe' => $recipe]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user