Skip to content

Commit

Permalink
Read me and traits
Browse files Browse the repository at this point in the history
  • Loading branch information
tanthammar committed May 17, 2021
1 parent a7f6529 commit 6f6c41c
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tanthammar/livewire-auto-routes",
"description": "A description for livewire-auto-routes.",
"description": "Auto generate routes for Laravel Livewire Components.",
"type": "package",
"license": "MIT",
"keywords": [
Expand Down
67 changes: 53 additions & 14 deletions readme.md
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.
14 changes: 14 additions & 0 deletions src/HasAuthRoute.php
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);
}
}
14 changes: 14 additions & 0 deletions src/HasGuestRoute.php
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);
}
}

0 comments on commit 6f6c41c

Please sign in to comment.