Skip to content

Commit

Permalink
Use the method to disable the component
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Sep 28, 2020
1 parent 60eb1e4 commit 7beb7a3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/BreadcrumbsComponent.php
Expand Up @@ -4,8 +4,8 @@

namespace Tabuna\Breadcrumbs;

use Illuminate\View\Component;
use Illuminate\Support\Collection;
use Illuminate\View\Component;

class BreadcrumbsComponent extends Component
{
Expand Down Expand Up @@ -71,15 +71,23 @@ public function generate(): Collection
return $this->breadcrumbs->current($this->parameters);
}

/**
* Determine if the component should be rendered.
*
* @return bool
*/
public function shouldRender(): bool
{
return $this->breadcrumbs->has($this->route);
}

/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|string
*/
public function render()
{
return $this->breadcrumbs->has($this->route)
? view('breadcrumbs::breadcrumbs')
: '';
return view('breadcrumbs::breadcrumbs');
}
}

0 comments on commit 7beb7a3

Please sign in to comment.