Formfeed-UK / nova-breadcrumbs

Augments Nova 4 Breadcrumbs with nesting and resource/static override methods
MIT License
20 stars 9 forks source link

resourceBreadcrumbs is not working #42

Open msucevan opened 8 months ago

msucevan commented 8 months ago

Nova version: v4.32.15 (Silver Surfer)

  public function resourceBreadcrumbs(NovaRequest $request, Breadcrumbs $breadcrumbs, array $breadcrumbArray) {
        Log::info('resourceBreadcrumbs' , ['request' => $request, 'breadcrumbs' => $breadcrumbs, 'breadcrumbArray' => $breadcrumbArray]);
        $breadcrumbs->items = [Breadcrumb::make('Home', '/')];
        return $breadcrumbArray;
    }

I even don't get the log, like is never called the function. I'm doing something wrong?

msucevan commented 8 months ago

    protected function resourceBreadcrumbs(NovaRequest $request, $resource, $breadcrumbArray) {

        if (method_exists($resource, "breadcrumbs")) { //why is just "breadcrumbs" and not "resourceBreadcrumbs" like described in the readme?
            return Arr::wrap($resource->breadcrumbs($request, $this, $breadcrumbArray));
        }

        if (!is_null(static::$resourceBreadcrumbCallback)) {
            return Arr::wrap(call_user_func_array(static::$resourceBreadcrumbCallback, [$request, $this, $breadcrumbArray]));
        }

        return $breadcrumbArray;
    }
samyouel commented 2 months ago

Same here... Yeah, if you replace breadcrumbs with resourceBreadcrumbs it seems to work for my use case, but not sure what other implications this has or if this destroys something else?

But in stead of calling

public function resourceBreadcrumbs(NovaRequest $request, Breadcrumbs $breadcrumbs, array $breadcrumbArray)

you can do:

public function breadcrumbs(NovaRequest $request, Breadcrumbs $breadcrumbs, array $breadcrumbArray) 
msucevan commented 2 months ago

Same here... Yeah, if you replace breadcrumbs with resourceBreadcrumbs it seems to work for my use case, but not sure what other implications this has or if this destroys something else?

But in stead of calling

public function resourceBreadcrumbs(NovaRequest $request, Breadcrumbs $breadcrumbs, array $breadcrumbArray)

you can do:

public function breadcrumbs(NovaRequest $request, Breadcrumbs $breadcrumbs, array $breadcrumbArray) 

Yes is what I did... but as the documentation suggest is to use resourceBreadcrumbs. Anyway looks that this repository is not either maitained