How to change the URL slug of a Laravel Nova resource

When you define a resource, Laravel Nova makes an educated guess regarding its URL slug. For example, the list of all OvalOfficeAddress resources appears at /nova/resources/oval-office-addresses.

But what if you prefer to display the list of Oval Office Addresses at /nova/resources/tweets instead?

Not a problem. Just override the uriKey method, as follows:

class OvalOfficeAddress extends Resource
{
  public function uriKey()
  {
    return "tweets";
  }
}

Sign up for my newsletter

A monthly round-up of blog posts, projects, and internet oddments.