Simplified database records management.

Overview

inspector logo

Simplified database records management. Inspector will let you take care of CRUD without taking over your frontend.

Example

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

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

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

Installation

You can install the package via composer:

composer require invoiceninja/inspector

Requirements

  • Laravel 8.x
  • PHP 7.4+

Philosophy

Inspector isn't your regular admin panel. It is meant to be used as part of the admin panel. That said, we wanted something that is lightweight and it doesn't take over your front end.

It doesn't care about your CSS framework, do you use Livewire or not, because you're in charge of integrating it. Don't worry, it's extremely simple.

Usage

Like we previously said, you're in charge of integrating Inspector, but we will give you the most simple examples here.

Start by creating one controller, we will name it TableController.

php artisan make:controller TableController

Showing tables in the database

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

Now, to show all these tables, you can make your own loop. To speed things up, we've provided some prebuilt components.

<x-inspector-tables :tables="$tables" />

This will show a nice preview of all tables in your database.

Tables
Failed jobs
Migrations
Password resets
Personal access tokens
Users

Awesome, let's make the link to the individual table page. We can do this by passing the show-route-name parameter in the component.

<x-inspector-tables :tables="$tables" show-route-name="tables.show" />

Note: Route name is fully optional. We're using a resourceful controller, following Laravel conventions.

By doing that, we should get a new "View" action in our table:

Table Action
Failed jobs View
Migrations View
Password resets View
Personal access tokens View
Users View

Showing table columns

It might be useful for you to preview table columns & their types. To achieve that we can use the getTableColumns method.

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

That will produce a nice table with all columns/types.

Column Type
id integer
migration string
batch integer

Showing table records

To show table records, we can make use of the getTableRecords method.

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),
    ]);
}
<x-inspector-records 
    :table="$table" 
    :columns="$columns"
    :records="$records" /> 

To generate a link to a specific record, pass show-route-name:

<x-inspector-records 
    :table="$table" 
    :columns="$columns"
    :records="$records"
    show-route-name="tables.edit" /> 

This will generate URL like this: /tables/{table}/edit?id=1.

# id migration batch
View 1 2014_10_12_000000_create_users_table 1

Showing & editing row in the table

Showing a page for the specific row is super simple. We can make use of the getTableRecord method.

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')),
    ]);
}
<x-inspector-record 
    :record="$record" 
    :table="$table"
    :columns="$columns"
    update-route-name="tables.update" />

This will generate the form with all columns as input fields & their values as part of input values.

Note: update-route-name is optional.

Updating table row

One thing that is left is updating the table row. As you can probably guess, Inspector provides a helper method - updateTableRecord.

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.');
}

Configuration

We did our best to make Inspector as configurable as possible. To tinker with a configuration file, make sure to publish it first.

php artisan vendor:publish --provider="InvoiceNinja\Inspector\InspectorServiceProvider"

With configuration published, you can control visible tables, as well as hidden, component classes & modify them as you wish.

Available methods

  • setConnectionName(string $connectionName): self - Set the database connection. By default it will pick up your default app connection.

  • getConnectionName(): string - Retrieve the current connection name.

  • getSchemaManager(): Doctrine\DBAL\Schema\AbstractSchemaManager - Retrieve current schema manager instance.

  • getTableNames(): array - Retrieve the list of table names in the database.

  • getTableSchema(string $table): Doctrine\DBAL\Schema\Table - Retrieve Table representation of table.

  • getTableColumns(string $table): array - Retrieve all columns for specified table.

  • getTable(string $table): Illuminate\Database\Query\Builder - Table instance of query builder.

  • getTableRecords(string $table, array $columns = ['*']): Illuminate\Support\Collection - Retrieve all records for the specified table.

  • getTableRecord(string $table, string $value, string $column = 'id'): mixed - Retrieve single record for specified table.

  • updateTableRecord(string $table, string $id, Request $request, string $column = 'id'): bool - Update specific table row.

  • validate(Request $request, string $table) - Validate specific request.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
Download Porn Adult XXX Videos Online Ready Site No Installation No Database Required

Download Porn Adult XXX Videos Online Ready Site No Installation No Database Required PHP / HTML How to USE Search Videos from any of the Supported Si

Vote based Question & Answer site built using Laravel 5.4, material design, x-editable and jQuery Upvote with email and database notifications.
Vote based Question & Answer site built using Laravel 5.4, material design, x-editable and jQuery Upvote with email and database notifications.

About Vote based Question & Answer site built using Laravel 5.4, material design, x-editable, jQuery Upvote and email/database notifications. Register

Database version control, made easy!

Database version control, made easy! dbv.php is a database version control web application featuring schema management, revision scripts, and more! Ch

Created simple login system and chat type website using mysql database along with php and html , css and javascript.

Created simple login system and chat type website using mysql database along with php and html , css and javascript.

An Online Movie Booking Website whose data is completely from a database

An Online Movie Booking Website whose data is completely from a database to ensure that it can be implemented in a real time scenario as any change of data needs to be done only in the database using SQL queries and the changes are immediately reflected.

 Well secured MySQL Database Login and Registration with an seperate dashboard for consumers and admins.
Well secured MySQL Database Login and Registration with an seperate dashboard for consumers and admins.

WebApplicationPHP Well secured MySQL Database Login and Registration with an seperate dashboard for consumers and admins. Functions Well secured MySQL

A micro web application providing a REST API on top of any relational database, using Silex and Doctrine DBAL

Microrest is a Silex provider to setting up a REST API on top of a relational database, based on a YAML (RAML) configuration file.

🔐 Password Manager written in PHP with MySQL database.
🔐 Password Manager written in PHP with MySQL database.

Password Manager A very basic password manager. Tech stack: PHP MySQL Bootstrap Setup Download and install XAMPP. Clone this repository: git clone htt

A monthly payment report using HTML, CSS, PHP and MySQL database
A monthly payment report using HTML, CSS, PHP and MySQL database

A monthly payment report using HTML, CSS, PHP and MySQL database

Releases(v1.0)
Owner
Invoice Ninja
An open-code invoicing app built with Laravel and Flutter
Invoice Ninja
SPFtoolbox is a Javascript and PHP app to look up DNS records such as SPF, MX, Whois, and more

SPFtoolbox is a Javascript and PHP app to look up DNS records such as SPF, MX, Whois, and more

Charles Barnes 216 Dec 30, 2022
Livewire component to show records according to their current status

Livewire Status Board Livewire component to show records/data according to their current status Preview Installation You can install the package via c

Andrés Santibáñez 288 Dec 24, 2022
DooTask is a lightweight open source online project task management tool that provides various document collaboration tools, online mind mapping, online flowcharting, project management, task distribution, instant IM, file management and other tools.

DooTask is a lightweight open source online project task management tool that provides various document collaboration tools, online mind mapping, online flowcharting, project management, task distribution, instant IM, file management and other tools.

kuaifan 3k Jan 5, 2023
Database management in a single PHP file

Adminer - Database management in a single PHP file Adminer Editor - Data manipulation for end-users https://www.adminer.org/ Supports: MySQL, MariaDB

Jakub Vrána 5.5k Jan 8, 2023
Open Source Voucher Management System is a web application for manage voucher. used PHP with Laravel Framework and use MySQL for Database.

Voucher Management System is a web application for manage voucher. You can create and manage your voucher. Voucher Management System is used PHP with Laravel Framework and use MySQL for Database.

Artha Nugraha Jonar 34 Sep 17, 2022
mini Project in Laravel and vue js. Real World Laravel 8x + vue js Dashboard.Task management and project management system

mini Project in Laravel and vue js. Real World Laravel 8x + vue js Dashboard.Task management and project management system. Dashboard features such as: Complete Dashboard, Custom Authentication, Email Verification, custom-login-register-forgot password (without jetstream).

Hasmukh Dharajiya 2 Sep 20, 2022
Laravel-Library-Management-system is nice to management library system...

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Eng Hasan Hajjar 2 Sep 30, 2022
Bulit PHP Twitter Clone IN OOP style and using MYSQL Database.

Bulit PHP Twitter Clone IN OOP style and using MYSQL Database. AJAX and Jquery for requests without reloading like Follow/unfollow, like, Search users, Show popups like comment , User lists, etc.

Amin 47 Dec 3, 2022
Bulk name lookup for database relations

Tatter\Roster Bulk name lookup for database relations in CodeIgniter 4 Quick Start Install with Composer: > composer require tatter/roster Create a Ro

Tatter Software 5 Jun 11, 2022
Vote based Question & Answer site built using Laravel 5.4, material design, x-editable and jQuery Upvote with email and database notifications.

About Vote based Question & Answer site built using Laravel 5.4, material design, x-editable, jQuery Upvote and email/database notifications. Register

Jorge A. Gonzalez 116 Nov 2, 2022