v
public function onRun()
{
try {
$this->products = $this->getProducts();
$this->category = $this->getCategory();
$this->parent = $this->getParent();
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
return \Response::make($this->controller->run('404'), 404);
}
}
protected function getParent(): Category
{
return Category::whereHas('prodcuts', function ($query) {
$query->whereSlug($this->param('slug'));
})->firstOrFail();
}