*/ private $recipes; /** * Create a new component instance. * * @param mixed $limit * @param mixed $id * @return void */ public function __construct(mixed $limit, mixed $id = null) { $this->limit = 3; if ($limit != null) { $this->limit = $limit; } if ($id != null) { $this->id = $id; $this->recipes = Recipe::query()->where('status', '1') ->where('id', '!=', $this->id)->inRandomOrder()->limit($this->limit)->get(); } else { $this->recipes = Recipe::query()->where('status', '1')->inRandomOrder()->limit($this->limit)->get(); } } /** * Get the view / contents that represent the component. * * @return \Illuminate\Contracts\View\View|\Closure|string */ public function render() { $recipes = $this->recipes; return view('fo.components.recipe-widget', compact('recipes')); } }