{"id":18949199,"url":"https://github.com/invoiceninja/inspector","last_synced_at":"2025-04-15T23:31:10.587Z","repository":{"id":56992873,"uuid":"401692561","full_name":"invoiceninja/inspector","owner":"invoiceninja","description":"Simplified database records management.","archived":false,"fork":false,"pushed_at":"2024-06-04T12:32:17.000Z","size":200,"stargazers_count":8,"open_issues_count":6,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-10-25T20:03:10.705Z","etag":null,"topics":["database","laravel","management","php"],"latest_commit_sha":null,"homepage":"https://invoiceninja.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/invoiceninja.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-31T12:20:25.000Z","updated_at":"2024-06-04T12:31:54.000Z","dependencies_parsed_at":"2024-06-19T10:12:25.079Z","dependency_job_id":null,"html_url":"https://github.com/invoiceninja/inspector","commit_stats":{"total_commits":79,"total_committers":2,"mean_commits":39.5,"dds":"0.025316455696202556","last_synced_commit":"29bc1ee7ae9d967287ecbd3485a2fee41a13e65f"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invoiceninja%2Finspector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invoiceninja%2Finspector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invoiceninja%2Finspector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invoiceninja%2Finspector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/invoiceninja","download_url":"https://codeload.github.com/invoiceninja/inspector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223688625,"owners_count":17186299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","laravel","management","php"],"created_at":"2024-11-08T13:16:06.500Z","updated_at":"2024-11-08T13:16:07.673Z","avatar_url":"https://github.com/invoiceninja.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/invoiceninja/inspector/main/resources/static/cover.png\" alt=\"inspector logo\"\u003e\n\u003c/p\u003e\n\n\u003c!-- [![Latest Version on Packagist](https://img.shields.io/packagist/v/invoiceninja/inspector.svg?style=flat-square)](https://packagist.org/packages/invoiceninja/inspector)\n[![Total Downloads](https://img.shields.io/packagist/dt/invoiceninja/inspector.svg?style=flat-square)](https://packagist.org/packages/invoiceninja/inspector)\n![GitHub Actions](https://github.com/invoiceninja/inspector/actions/workflows/main.yml/badge.svg) --\u003e\n\nSimplified database records management. Inspector will let you take care of [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) without taking over your frontend.\n\n## Example\n```php\n$inspector = new \\InvoiceNinja\\Inspector\\Inspector();\n\n// List all tables in the database\n$tables = $inspector-\u003egetTableNames();\n\n// Get table columns\n$columns = $inspector-\u003egetTableColumns('users');\n```\n\n- [Example](#example)\n- [Installation](#installation)\n- [Requirements](#requirements)\n- [Philosophy](#philosophy)\n- [Usage](#usage)\n  - [Showing tables in the database](#showing-tables-in-the-database)\n  - [Showing table columns](#showing-table-columns)\n  - [Showing table records](#showing-table-records)\n  - [Showing \u0026 editing row in the table](#showing--editing-row-in-the-table)\n  - [Updating table row](#updating-table-row)\n- [Configuration](#configuration)\n- [Available methods](#available-methods)\n- [Contributing](#contributing)\n  - [Security](#security)\n- [Credits](#credits)\n- [License](#license)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require invoiceninja/inspector\n```\n## Requirements\n- Laravel 8.x\n- PHP 7.4+\n\n## Philosophy\nInspector 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. \n\nIt 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.\n\n## Usage\n\nLike we previously said, **you're in charge** of integrating Inspector, but we will give you the most simple examples here.\n\nStart by creating one controller, we will name it `TableController`.\n\n```bash\nphp artisan make:controller TableController\n```\n\n### Showing tables in the database\n\n```php\npublic function index(\\InvoiceNinja\\Inspector\\Inspector $inspector)\n{\n    return view('tables.index', [\n        'tables' =\u003e $inspector-\u003egetTableNames(),\n    ]);\n}\n```\n\nNow, to show all these tables, you can make your own loop. To speed things up, we've provided some prebuilt components.\n\n```html\n\u003cx-inspector-tables :tables=\"$tables\" /\u003e\n```\n\nThis will show a nice preview of all tables in your database.\n\n| Tables                 |\n|------------------------|\n| Failed jobs            |\n| Migrations             |\n| Password resets        |\n| Personal access tokens |\n| Users                  |\n\nAwesome, let's make the link to the individual table page. We can do this by passing the `show-route-name` parameter in the component.\n\n```html\n\u003cx-inspector-tables :tables=\"$tables\" show-route-name=\"tables.show\" /\u003e\n```\n\n\u003e Note: Route name is fully **optional**. We're using a resourceful controller, following Laravel conventions.\n\nBy doing that, we should get a new \"View\" action in our table:\n\n| Table                  | Action |\n|------------------------|--------|\n| Failed jobs            | View   |\n| Migrations             | View   |\n| Password resets        | View   |\n| Personal access tokens | View   |\n| Users                  | View   |\n\n### Showing table columns\n\nIt might be useful for you to preview table columns \u0026 their types. To achieve that we can use the `getTableColumns` method.\n\n```php\npublic function show(string $table, \\InvoiceNinja\\Inspector\\Inspector $inspector)\n{\n    return view('tables.show', [\n        'columns' =\u003e $inspector-\u003egetTableColumns($table),\n    ]);\n}\n```\n\n```html\n\u003cx-inspector-columns :columns=\"$columns\" /\u003e\n```\n\nThat will produce a nice table with all columns/types.\n\n| Column    | Type    |\n|-----------|---------|\n| id        | integer |\n| migration | string  |\n| batch     | integer |\n\n### Showing table records\n\nTo show table records, we can make use of the `getTableRecords` method.\n\n```php\npublic function show(string $table, \\InvoiceNinja\\Inspector\\Inspector $inspector)\n{\n    return view('tables.show', [\n        'table' =\u003e $inspector-\u003egetTableSchema($table),\n        'columns' =\u003e $inspector-\u003egetTableColumns($table),\n        'records' =\u003e $inspector-\u003egetTableRecords($table),\n    ]);\n}\n```\n\n```html\n\u003cx-inspector-records \n    :table=\"$table\" \n    :columns=\"$columns\"\n    :records=\"$records\" /\u003e \n```\n\nTo generate a link to a specific record, pass `show-route-name`:\n\n```html\n\u003cx-inspector-records \n    :table=\"$table\" \n    :columns=\"$columns\"\n    :records=\"$records\"\n    show-route-name=\"tables.edit\" /\u003e \n```\n\nThis will generate URL like this: `/tables/{table}/edit?id=1`.\n\n| #    | id | migration                            | batch |\n|------|----|--------------------------------------|-------|\n| View | 1  | 2014_10_12_000000_create_users_table | 1     |\n\n### Showing \u0026 editing row in the table\n\nShowing a page for the specific row is super simple. We can make use of the `getTableRecord` method.\n\n```php\npublic function edit(string $table, \\Illuminate\\Http\\Request $request, \\InvoiceNinja\\Inspector\\Inspector $inspector)\n{\n    return view('tables.edit', [\n        'table' =\u003e $inspector-\u003egetTableSchema($table),\n        'columns' =\u003e $inspector-\u003egetTableColumns($table),\n        'record' =\u003e $inspector-\u003egetTableRecord($table, $request-\u003equery('id')),\n    ]);\n}\n```\n\n```html\n\u003cx-inspector-record \n    :record=\"$record\" \n    :table=\"$table\"\n    :columns=\"$columns\"\n    update-route-name=\"tables.update\" /\u003e\n```\n\nThis will generate the form with all columns as input fields \u0026 their values as part of input values.\n\n\u003e Note: `update-route-name` is **optional**.\n\n### Updating table row\n\nOne thing that is left is updating the table row. As you can probably guess, Inspector provides a helper method - `updateTableRecord`.\n\n```php\npublic function update(string $table, \\Illuminate\\Http\\Request $request, \\InvoiceNinja\\Inspector\\Inspector $inspector)\n{\n    $inspector-\u003evalidate($request, $table);\n\n    $success = $inspector-\u003eupdateTableRecord($table, $request-\u003equery('id'), $request);\n\n    if ($success) {\n        return back()-\u003ewithMessage('Successfully updated the record.');\n    }\n\n    return back()-\u003ewithMessage('Oops, something went wrong.');\n}\n```\n\n## Configuration\nWe did our best to make Inspector as configurable as possible. To tinker with a configuration file, make sure to publish it first.\n\n```bash\nphp artisan vendor:publish --provider=\"InvoiceNinja\\Inspector\\InspectorServiceProvider\"\n```\n\nWith configuration published, you can control visible tables, as well as hidden, component classes \u0026 modify them as you wish.\n\n## Available methods\n\n- `setConnectionName(string $connectionName): self` - Set the database connection. By default it will pick up your default app connection.\n\n- `getConnectionName(): string` - Retrieve the current connection name.\n\n- `getSchemaManager(): Doctrine\\DBAL\\Schema\\AbstractSchemaManager` - Retrieve current schema manager instance.\n\n- `getTableNames(): array` - Retrieve the list of table names in the database.\n\n- `getTableSchema(string $table): Doctrine\\DBAL\\Schema\\Table` - Retrieve `Table` representation of table.\n\n- `getTableColumns(string $table): array` - Retrieve all columns for specified table.\n\n- `getTable(string $table): Illuminate\\Database\\Query\\Builder` - Table instance of query builder.\n\n- `getTableRecords(string $table, array $columns = ['*']): Illuminate\\Support\\Collection` - Retrieve all records for the specified table.\n\n- `getTableRecord(string $table, string $value, string $column = 'id'): mixed` - Retrieve single record for specified table.\n\n- `updateTableRecord(string $table, string $id, Request $request, string $column = 'id'): bool` - Update specific table row.\n\n- `validate(Request $request, string $table)` - Validate specific request.\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/invoiceninja/invoiceninja/blob/master/CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security-related issues, please email contact@invoiceninja.com instead of using the issue tracker.\n\n## Credits\n\n-   [Benjamin Beganović](https://github.com/invoiceninja)\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finvoiceninja%2Finspector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finvoiceninja%2Finspector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finvoiceninja%2Finspector/lists"}