Update README.md

This commit is contained in:
Tony Roy 2021-03-13 08:21:29 -04:00 committed by GitHub
commit 5a69d2c2d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,2 +1,92 @@
# laravel-netbox
Netbox API driver for Laravel
## Laravel NetBox
NetBox is an open source web application designed to help manage and document computer networks.
### Table of contents
- [Installation](#installation)
- [Usage](#usage)
- [Tests](#tests)
### Installation
Install this package with composer:
```
composer require wickedsoft/laravel-netbox
```
Copy the config files for the HostFact-plugin
```
php artisan vendor:publish --provider="wickedsoft\NetBox\ServiceProvider" --tag="config"
```
Add the HostFact credentials to your `.env` file
```
NETBOX_DEFAULT_URL=
NETBOX_DEFAULT_KEY=
```
### Usage
#### Authentication [users]
It's possible to use a custom `netbox` authentication driver to login users in your application, by default the UserProfile will be cached for 60 minutes
```php
// config/auth.php
'providers' => [
'netbox' => [
'driver' => 'netbox'
],
]
// Auth::attempt
if(Auth::attempt(['username' => $username, 'password' => $password]))
{
dd(Auth::user(), Auth::id());
}
```
#### Multiple Installs [config]
If you want to work with more Netbox installs, you can define more netboxes in the `config/netbox.php` file
```php
// config/netbox.php
'panels' => [
'default' => [
'url' => env('NETBOX_DEFAULT_URL'),
'key' => env('NETBOX_DEFAULT_KEY'),
],
'chicago' => [
'url' => env('NETBOX_CHI_URL'),
'key' => env('NETBOX_CHI_KEY'),
],
],
```
#### Multiple Installs [normal usage]
To use another netbox than your default one, you can specify it with the panel-method
```php
// UsersController
public function getIndex()
{
$users = NetBox::panel('chicago')->users()->list([
'limit' => 20
]);
//
}
```
#### Multiple Installs [dependency injection]
```php
// Route
Route::get('/netbox/{netBox}/users', ['as' => 'netbox/users', 'uses' => 'UsersController@getIndex']);
Route::bind('netBox', function ($value, $route) {
app('NetBox')->panel($value);
return app('NetBox');
});
// UsersController
public function getIndex(NetBox $netBox)
{
$users = $netBox->users()->list([
'limit' => 20
]);
//
}
- - -