NetBox API client for PHP
Find a file
2021-03-13 08:21:29 -04:00
config Update netbox.php 2021-03-12 14:21:23 -04:00
src Delete Ip.php 2021-03-12 23:43:53 -04:00
composer.json Update composer.json 2021-03-11 20:50:25 -04:00
LICENSE.md Update and rename LICENSE to LICENSE.md 2021-03-10 17:12:25 -04:00
README.md Update README.md 2021-03-13 08:21:29 -04:00

Laravel NetBox

NetBox is an open source web application designed to help manage and document computer networks.

Table of contents

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

// 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

// 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

// UsersController
public function getIndex()
{
    $users = NetBox::panel('chicago')->users()->list([
        'limit' => 20
    ]);

    //
}

Multiple Installs [dependency injection]

// 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
    ]);

    //
}

- - -