Log1x/crumb

Undefined variable: items

hlinton7 opened this issue ยท 2 comments

Hi,

I am getting an error in my code, it doesn't seem to be passing the variable $items, so when using var_dump the error shows.

I have acorn installed.

Also to note, it seems it isn't registering the Breadcrumb component, as when I echo any text it won't show either.

This is my component file and linking to the correct template file.

<?php

namespace App\View\Components;

use Roots\Acorn\View\Component;
use Log1x\Crumb\Facades\Crumb;

class Breadcrumb extends Component
{
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * The breadcrumb items.
     *
     * @return string
     */
    public function items()
    {
        return Crumb::build()->toArray();
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\View\View|string
     */
    public function render()
    {
        return $this->view('components.breadcrumb');
    }
}
ouun commented

Hi @hlinton7,
just stumbled over this, too. To include the component into a view, you need to use <x-breadcrumb /> instead of @include('components.breadcrumb').

Kind regards

@ouun I actually got this working that way too, forgot to close the issue. Thank you for your help ๐Ÿ™Œ๐Ÿป