📏Route

to generate a route for current resource to pass it to your action you can do that by just 1 command

Using

to create a new route inside your resource class you can use this command

php artisan vilt:route

It will ask you to input route name and route type, route method, route class, target class and the resource class name and the module name and it will generate an action class for you like this

class CustomRoute extends Routes
{
    public function setup(): void
    {
         $this->name('custom');
         $this->type('post');
         $this->method('customMethod');
         $this->controller(CustomResource::class);
         $this->path('custom');
    }
}

set your data and define the route class on ResourceName/Components.php trait like this

public function components(): array {
  return [
     Component::make(CustomRoute::class)->route()
  ];
} 

you will show a new route when you run php artisan route:list

Last updated