Search code examples
laravellaravel-nova

Laravel Nova - Point Nova path to resource page


I need to point Nova path to a resouce. So that when a user login, he`ll directed to that particular resource.

I have updated this path in /config/nova.php:

'path' => '/crm/resources/clients' 

Now after login, I can see the URL updated. But the page is still Welcome Nova page.

Any idea on this?


Solution

  • You can create a custom Asset or Tool to hook into the Vue Router. In our specific case, we wanted to redirect to our custom tool instead of a resource or the dashboard. Creating a tool generates a tool.js file where it allows you to hook into the vue-router.


    Redirect from the dashboard to a named route

    router.beforeEach((to, from, next) => {
       if (to.name == "dashboard.custom") {
          next({
              name: "reports" // Route added by our tool
          });
       } else {
          next();
       }
    });
    

    Redirect from the dashboard to a resource index

    router.beforeEach((to, from, next) => {
       if (to.name == "dashboard.custom") {
          next({
              name: "index",
              params: {
                resourceName: 'model' // replace with resource name
              }
          });
       } else {
          next();
       }
    });
    

    Note resourceName is the name of the dynamic segment defined in the index route.

    Showing why resourceName is used as the property name in the code above