limit = 3; if($limit != null ) $this->limit = $limit; if($id !=null ) { $this->id=$id; $this->recipes = Recipe::where('live', '1')->where('id', '!=', $this->id )->inRandomOrder()->limit($this->limit)->get(); }else { $this->recipes = Recipe::where('live', '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('components.recipe-widget', compact('recipes')); } }