ldc-nature-and-respect/app/View/Components/RecipeCard.php

45 lines
777 B
PHP
Raw Normal View History

2022-11-18 12:39:03 +01:00
<?php
namespace App\View\Components;
use Illuminate\View\Component;
use App\Recipe;
class RecipeCard extends Component
{
2022-12-23 17:24:09 +00:00
/**
* @var integer
*/
2022-11-18 12:39:03 +01:00
public $id;
2022-11-18 15:35:39 +01:00
2022-12-23 17:24:09 +00:00
/**
* Recipe model
*
* @var \App\Recipe
*/
2022-11-18 12:39:03 +01:00
public $recipe;
/**
* Create a new component instance.
*
2022-12-23 17:24:09 +00:00
* @param integer $id
2022-11-18 12:39:03 +01:00
* @return void
*/
2022-12-23 17:24:09 +00:00
public function __construct(int $id)
2022-11-18 15:35:39 +01:00
{
2022-11-18 12:39:03 +01:00
$this->recipe = Recipe::where('id', $id)->first();
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
$recipe = $this->recipe;
2022-11-18 15:35:39 +01:00
2022-11-18 12:39:03 +01:00
return view('components.recipe-card', compact('recipe'));
}
}