Skip to content

Commit 303a3de

Browse files
committed
chore: added new documentation section for livewire support
1 parent 9c5fc21 commit 303a3de

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Automatically Route Generator & Discovery Package for Laravel.
2222
- Livewire routes support [included Volt] _(in v2.x)_
2323

2424
## Install
25-
2625
Supported Laravel Versions:
2726
- v2.x: Laravel 10 and later
2827
- v1.x: Laravel 6 and later ([see the source](https://github.com/izniburak/laravel-auto-routes/tree/1.x))
@@ -339,6 +338,39 @@ Route::auto('/test', 'Backend.TestController');
339338
Route::auto('/test', 'Backend\\TestController');
340339
```
341340

341+
## with Livewire & Volt
342+
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.
372+
373+
342374
## Support
343375
You can use Issues
344376

0 commit comments

Comments
 (0)