You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can define Livewire or Volt component routes directly in your controller by using Auto Routes package!
343
+
For this, you should add new methods which have prefix `volt` or `wire`. That's it. Auto Routes package will automatically discover your Livewire routes and add them into the application routes.
344
+
345
+
```php
346
+
namespace App\Http\Controllers;
347
+
348
+
use Illuminate\Http\Request;
349
+
350
+
class TestController extends Controller
351
+
{
352
+
/**
353
+
* URL: "/test/foo"
354
+
* id parameter must be numeric.
355
+
*/
356
+
public function voltFoo(): string
357
+
{
358
+
// resources/views/livewire/pages/foo.blade.php
359
+
return 'pages.foo';
360
+
}
361
+
362
+
/**
363
+
* URL: "/test/bar"
364
+
*/
365
+
public function wireBar(): string
366
+
{
367
+
return \App\Livewire\TestComponent::class;
368
+
}
369
+
}
370
+
```
371
+
As you see; for both methods, you must return a string value that Volt component path string or Livewire component class string. Now, you can access your Livewire components.
0 commit comments