Download the PHP package invoiceninja/inspector without Composer
On this page you can find all versions of the php package invoiceninja/inspector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download invoiceninja/inspector
More information about invoiceninja/inspector
Files in invoiceninja/inspector
Package inspector
Short Description Simplified database records management
License MIT
Homepage https://github.com/invoiceninja/inspector
Informations about the package inspector
Simplified database records management. Inspector will let you take care of CRUD without taking over your frontend.
Example
- Example
- Installation
- Requirements
- Philosophy
- Usage
- Showing tables in the database
- Showing table columns
- Showing table records
- Showing & editing row in the table
- Updating table row
- Configuration
- Available methods
- Contributing
- Security
- Credits
- License
Installation
You can install the package via composer:
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
.
Showing tables in the database
Now, to show all these tables, you can make your own loop. To speed things up, we've provided some prebuilt components.
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.
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.
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.
To generate a link to a specific record, pass show-route-name
:
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.
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
.
Configuration
We did our best to make Inspector as configurable as possible. To tinker with a configuration file, make sure to publish it first.
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
- RetrieveTable
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
- Benjamin Beganović
- All Contributors
License
The MIT License (MIT). Please see License File for more information.