PHP code example of invoiceninja / inspector

1. Go to this page and download the library: Download invoiceninja/inspector library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

invoiceninja / inspector example snippets


$inspector = new \InvoiceNinja\Inspector\Inspector();

// List all tables in the database
$tables = $inspector->getTableNames();

// Get table columns
$columns = $inspector->getTableColumns('users');

public function index(\InvoiceNinja\Inspector\Inspector $inspector)
{
    return view('tables.index', [
        'tables' => $inspector->getTableNames(),
    ]);
}

public function show(string $table, \InvoiceNinja\Inspector\Inspector $inspector)
{
    return view('tables.show', [
        'columns' => $inspector->getTableColumns($table),
    ]);
}

public function show(string $table, \InvoiceNinja\Inspector\Inspector $inspector)
{
    return view('tables.show', [
        'table' => $inspector->getTableSchema($table),
        'columns' => $inspector->getTableColumns($table),
        'records' => $inspector->getTableRecords($table),
    ]);
}

public function edit(string $table, \Illuminate\Http\Request $request, \InvoiceNinja\Inspector\Inspector $inspector)
{
    return view('tables.edit', [
        'table' => $inspector->getTableSchema($table),
        'columns' => $inspector->getTableColumns($table),
        'record' => $inspector->getTableRecord($table, $request->query('id')),
    ]);
}

public function update(string $table, \Illuminate\Http\Request $request, \InvoiceNinja\Inspector\Inspector $inspector)
{
    $inspector->validate($request, $table);

    $success = $inspector->updateTableRecord($table, $request->query('id'), $request);

    if ($success) {
        return back()->withMessage('Successfully updated the record.');
    }

    return back()->withMessage('Oops, something went wrong.');
}
bash
php artisan make:controller TableController
bash
php artisan vendor:publish --provider="InvoiceNinja\Inspector\InspectorServiceProvider"