-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a7f6529
commit 6f6c41c
Showing
4 changed files
with
82 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,74 @@ | ||
# livewire-auto-routes | ||
Auto generate routes for Laravel Livewire Components. | ||
|
||
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) | ||
[![Travis](https://img.shields.io/travis/tanthammar/livewire-auto-routes.svg?style=flat-square)]() | ||
[![Total Downloads](https://img.shields.io/packagist/dt/tanthammar/livewire-auto-routes.svg?style=flat-square)](https://packagist.org/packages/tanthammar/livewire-auto-routes) | ||
|
||
## Install | ||
`composer require tanthammar/livewire-auto-routes` | ||
## Installation | ||
``` | ||
composer require tanthammar/livewire-auto-routes | ||
``` | ||
|
||
## Usage | ||
Write a few lines about the usage of this package. | ||
You generate routes via traits or by adding a `route()` method to your Livewire component. | ||
|
||
## Testing | ||
Run the tests with: | ||
|
||
``` bash | ||
vendor/bin/phpunit | ||
### Guest route | ||
Applies the `guest` middleware. | ||
<br>**The property is used to generate both the route name and url.** | ||
|
||
```php | ||
use Tanthammar\LivewireAutoRoutes\HasGuestRoute; | ||
|
||
class FooComponent | ||
{ | ||
use HasGuestRoute; | ||
protected string $guestRoute = 'foo'; | ||
} | ||
``` | ||
|
||
### Auth route | ||
Applies the `auth` middleware. | ||
<br>**The property is used to generate both the route name and url.** | ||
|
||
```php | ||
use Tanthammar\LivewireAutoRoutes\HasAuthRoute; | ||
|
||
class FooComponent | ||
{ | ||
use HasAuthRoute; | ||
protected string $authRoute = 'foo'; | ||
} | ||
``` | ||
|
||
### Custom route | ||
* `use Illuminate\Support\Facades\Route` | ||
* `route()` | ||
|
||
```php | ||
use Illuminate\Support\Facades\Route; | ||
|
||
class FooComponent | ||
{ | ||
public function route() //do not add any return type | ||
{ | ||
return Route::get('foo', static::class) | ||
->middleware('auth') //default middleware is 'web' | ||
->name('foo'); | ||
} | ||
} | ||
``` | ||
|
||
|
||
## Changelog | ||
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. | ||
|
||
## Contributing | ||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
|
||
## Credits | ||
|
||
- [Tina Hammar](https://github.com/tanthammar) | ||
- [All Contributors](https://github.com/tanthammar/livewire-auto-routes/contributors) | ||
|
||
## Security | ||
If you discover any security-related issues, please email tinahammar@gmail.com instead of using the issue tracker. | ||
If you discover any security-related issues, please open an issue. | ||
|
||
## License | ||
The MIT License (MIT). Please see [License File](/LICENSE.md) for more information. | ||
The MIT License (MIT). Please see [License File](/LICENSE.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
|
||
namespace Tanthammar\LivewireAutoRoutes; | ||
|
||
use Illuminate\Support\Facades\Route; | ||
|
||
trait HasAuthRoute | ||
{ | ||
public function route() | ||
{ | ||
return Route::get($this->authRoute, static::class)->middleware('auth')->name($this->authRoute); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
|
||
namespace Tanthammar\LivewireAutoRoutes; | ||
|
||
use Illuminate\Support\Facades\Route; | ||
|
||
trait HasGuestRoute | ||
{ | ||
public function route() | ||
{ | ||
return Route::get($this->guestRoute, static::class)->middleware('guest')->name($this->guestRoute); | ||
} | ||
} |