Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'length' of undefined #2627

Closed
ankkk opened this issue May 19, 2020 · 2 comments
Closed

Cannot read property 'length' of undefined #2627

ankkk opened this issue May 19, 2020 · 2 comments

Comments

@ankkk
Copy link

ankkk commented May 19, 2020

  • Laravel Version: 7.11.0
  • Nova Version: 3.6.0
  • PHP Version: 7.4
  • Database Driver & Version: Postgres 12
  • Operating System and Version: Mac OS (10.15.4)
  • Browser type and version: Chrome 83 (Beta)

Description:

I have a model with name: Card. When trying to open a resource , I get an error:

TypeError: Cannot read property 'length' of undefined

And network 200 GET response:

[{"width":"full","component":"help","prefixComponent":false,"onlyOnDetail":false}]
@alanpilloud
Copy link

I also had the same issue. This comes from the resource being also named Card.

Then, I noticed that this warning was shown after the resource creation :

You *must* override the uriKey method for your Card resource.

I found the solution here : #857

Which is to add this method in the Nova resource :

/**
 * Get the URI key for the resource.
 *
 * @return string
 */
public static function uriKey()
{
    return 'kard';
}

@jbrooksuk
Copy link
Member

When you generate a resource, if it's using a reserved name - like "Card" - you are asked to override the uriKey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants