Skip to content

Commit

Permalink
chore: Added usability for route
Browse files Browse the repository at this point in the history
  • Loading branch information
joserick authored Mar 4, 2024
1 parent ae44508 commit 96eea3e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

![laravel_livewire_discover.jpg](https://joserick.com/livewire_discover.jpg)
# Laravel Livewire Discover
![Packagist Downloads](https://img.shields.io/packagist/dt/joserick/laravel-livewire-discover?color=blue) ![GitHub License](https://img.shields.io/github/license/joserick/laravel-livewire-discover) ![GitHub Release](https://img.shields.io/github/v/release/joserick/laravel-livewire-discover?color=2da711)
Expand All @@ -18,13 +19,12 @@ Add to *AppServiceProvider.php*
public function boot(): void
{
// Load multiples namespace for Livewire components.
Livewire::discover('Namespace\\Livewire', 'my-components');
Livewire::discover('Namespaces\\Livewire', 'my-components');
Livewire::discover('User\\Repository\\Livewire', 'new-components');
...
}
```
#### Or
Or use the config: *'config/laravel-livewire-discover.php'*
**Or** use the config: *'config/laravel-livewire-discover.php'*
``` bash
# Publish the config
php artisan vendor:publish --tag livewire-discover-config
Expand All @@ -33,16 +33,25 @@ php artisan vendor:publish --tag livewire-discover-config
// Load the namespace to Livewire components.
'class_namespaces' => [
// 'prefix' => 'namespace\\package',
'my-components' => 'Namespace\\Livewire',
'my-components' => 'Namespaces\\Livewire',
'new-components' => 'User\\Repository\\Livewire',
],
```
## Use
``` html
// Call components.
<!-- Call Livewire Components. -->
<livewire:my-components-devices /> <!-- Class: Namespace\Livewire\Devices; -->
<livewire:new-components-devices-table /> <!-- Class: User\Repository\Livewire\DevicesTable; -->
```
#### Or
``` php
// Load Livewire Component from Route
use Namespaces\Livewire\Devices;
use User\Repository\Livewire\DevicesTable;

Route::get('/devices', Devices::class); // resolve name my-components-devices
Route::get('/devices_table', DevicesTable::class); // resolve name new-components-devices-table
```
## License

The GNU Public License (GPLv3). Please see [License File](https://github.com/joserick/laravel-livewire-discover/blob/master/LICENSE) for more information.

0 comments on commit 96eea3e

Please sign in to comment.