{"id":19450842,"url":"https://github.com/morning-train/wp-database-model-admin-ui","last_synced_at":"2026-05-03T12:39:38.909Z","repository":{"id":142674898,"uuid":"613897275","full_name":"Morning-Train/wp-database-model-admin-ui","owner":"Morning-Train","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-09T11:31:13.000Z","size":244,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-03T08:35:35.794Z","etag":null,"topics":["database","eloquent","php","wordpress","wp"],"latest_commit_sha":null,"homepage":null,"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/Morning-Train.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-14T13:44:45.000Z","updated_at":"2023-04-11T07:53:53.000Z","dependencies_parsed_at":"2023-11-09T12:44:22.804Z","dependency_job_id":"20ce70b0-beb6-4929-a7f4-7fdb4bc11b72","html_url":"https://github.com/Morning-Train/wp-database-model-admin-ui","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/Morning-Train/wp-database-model-admin-ui","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-database-model-admin-ui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-database-model-admin-ui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-database-model-admin-ui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-database-model-admin-ui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morning-Train","download_url":"https://codeload.github.com/Morning-Train/wp-database-model-admin-ui/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-database-model-admin-ui/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263772337,"owners_count":23509103,"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","eloquent","php","wordpress","wp"],"created_at":"2024-11-10T16:39:14.969Z","updated_at":"2026-05-03T12:39:38.868Z","avatar_url":"https://github.com/Morning-Train.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Morningtrain\\WP\\DatabaseModelAdminUi\n\nAutogenerated Wordpress Admin Tables, for Eloquent Models.\n\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Getting Started](#getting-started)\n  - [Installation](#installation)\n- [Dependencies](#dependencies)\n- [Usage](#usage)\n  - [Initializing package](#initializing-package)\n  - [Use for an Eloquent Model](#use-for-an-eloquent-model)\n- [Classes](#classes)\n  - [ModelPage](#modelpage)\n  - [Column](#column)\n  - [RowAction](#rowaction)\n  - [AdminTableView](#admintableview)\n  - [AdminTableExtraTablenav](#admintableextratablenav)\n  - [ViewPage](#viewpage)\n  - [AcfEditPage](#acfeditpage)\n  - [AcfLoadField](#acfloadfield)\n  - [MetaBox](#metabox)\n- [Contributing](#contributing)\n  - [Bug Report](#bug-report)\n  - [Support Questions](#support-questions)\n  - [Pull Requests](#pull-requests)\n- [Credits](#credits)\n- [License](#license)\n\n\n## Introduction\nMake it easy, to create a WordPress Admin Table CRUD.  \n**Overview**: Makes a WordPress Admin Table, with the data from the Eloquent Model.  \n\n**Create**: Allows to create a new instance of the Eloquent Model, from an ACF group.  \n**Read**: Make a view page, where the data from the instance is displayed.  \n**Update**: Allows to update an instance of the Eloquent Model, from an ACF group.  \n**Delete**: Allows to delete an instance of the Eloquent Model.\n\n**IMPORTANT**:  \nYou will need ACF (Advanced Custom Fields) to get the _Create_ and _Update_ parts to work.\n\n## Getting Started\n\nTo get started install the package as described below in [Installation](#installation).\n\nTo use the tool have a look at [Usage](#usage)\n\n\n### Installation\n\nInstall with composer\n\n```bash\ncomposer require morningtrain/wp-database-model-admin-ui\n```\n\n\n## Dependencies\n\n- [morningtrain/php-loader](https://packagist.org/packages/morningtrain/php-loader)\n- [morningtrain/wp-database](https://packagist.org/packages/morningtrain/wp-database)\n- [morningtrain/wp-hooks](https://packagist.org/packages/morningtrain/wp-hooks)\n- [morningtrain/wp-view](https://packagist.org/packages/morningtrain/wp-view)\n\n\n\n## Usage\n\n### Initializing package\n\nInitialize `\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI` with the folder, where all the Eloquent Models is located.\n\n```php\n\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::setup(__DIR__ . \"/app/Models\");\n```\n\n### Use for an Eloquent Model\n\nWhen an Admin Table need to be show, for an Eloquent Model, this need to be register in.  \nTo do this, on each Model class, there will be called a static method called `setupAdminUi`.  \nTo start of, use `\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::modelPage()` method and give it a slug and an Eloquent Model class.  \nThe wrapper method has the following parameters:\n\n- `string $slug`\n- `string $model`\n\n\nWhen this is done, we need to register it. This is done by:\n```php\n\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::modelPage(string, string)\n    -\u003eregister();\n```\n\nThis is all there is to get started with an Admin Table overview.  \nThis will show an Admin Table overview, with all it's columns.  \n\nThe ModelPage can be customized, with different things. To se a list of all the settings, see [ModelPage](#modelpage).\n\n## Classes\n\n### ModelPage\n\n##### _Page Title_  \nSets the value to the page title, for the Admin Table.  \nDefault: `Admin Table`\n\n```php\n-\u003ewithPageTitle(string)\n```\n\n##### _Menu Title_\nSets the value to the menu title, for the Admin Table.  \nDefault: `Admin Table`\n\n```php\n-\u003ewithMenuTitle(string)\n```\n\n##### _Capability_\nSets the value, that the user needs, for viewing the Admin Table.  \nDefault: `manage_options`\n\n```php\n-\u003ewithCapability(string)\n```\n\n##### _Icon Url_\nSets the value for the Admin Table admin menu icon.  \nDefault: **_empty value_**\n\n```php\n-\u003ewithIconUrl(string)\n```\n\n##### _Position_\nSets the value for the Admin Table admin menu position.  \nDefault: `null`\n\n```php\n-\u003ewithPosition(int)\n```\n\n##### _Search button text_\nSets the value for the Admin Table search button text.  \nDefault: `__('Search')`\n\n```php\n-\u003ewithSearchButtonText(string)\n```\n\n##### _Columns_\nSets the value as columns, for the Admin Table.  \nDefault: `all columns on the Model`\n\nThis one takes an array of the `Column` classes.  \nThe `Column` can be customized, with different things. To se a list of all the settings, see [Column](#column).\n\n```php\n-\u003ewithColumns(array)\n```\n\n##### _Row Actions_\nSets the value as row actions, for the Admin Table.  \nDefault: `[]`\n\nIf method `-\u003ewithViewPage()` is in use, it will add a default **View** action to each row.  \nIf method `-\u003ewithAcfEditPage()` is in use, it will add a default **Edit** action to each row.  \nIf method `-\u003emakeRemovable()` is in use, it will add a default **Delete** action to each row.\n\nThis one takes an array of the `RowAction` classes.  \nThe `RowAction` can be customized, with different things. To se a list of all the settings, see [RowAction](#rowaction).\n\n```php\n-\u003ewithRowActions(array)\n```\n\n##### _Modify Query Callback_\nReturn the `callback|string` modified `\\Illuminate\\Database\\Eloquent\\Builder`.  \nDefault: `null`\nParameters in callback:\n- `\\Illuminate\\Database\\Eloquent\\Builder $query`\n\n```php\n-\u003ewithModifyQueryCallback(\\Illuminate\\Database\\Eloquent\\Builder)\n```\n\n##### _Admin Table Views_\nSet up the Admin Table views.  \nDefault: `[]`\n\nThis one takes an array of the `AdminTableViews` classes.  \nThe `AdminTableViews` can be customized, with different things. To se a list of all the settings, see [AdminTableViews](#admintableview).\n\n```php\n-\u003ewithAdminTableViews(array)\n```\n\nYou can also add views by using the `-\u003eaddAdminTableViewsCallback()` method instead. This should be used when having dynamic views to avoid using resources when not necessary.\n\nReturn the an array  array of `AdminTableViews` instances.    \nDefault: `null`  \nParameters in callback:\n- `ModelPage $modelPage`\n\nThe `AdminTableViews` can be customized, with different things. To se a list of all the settings, see [AdminTableViews](#admintableview).\n\n```php\n-\u003eaddAdminTableViewsCallback(callback)\n```\n\n##### _Admin Table Extra Tablenavns_\nSet up the Admin Table extra tablenavns.  \nThis one is split up into two methods, to have one for the top and one for the bottom.  \nDefault: `[]`\n\nBoth methods takes an array of the `AdminTableExtraTablenav` classes.  \nThe `AdminTableExtraTablenav` can be customized, with different things. To se a list of all the settings, see [AdminTableExtraTablenav](#admintableextratablenav).\n\n```php\n-\u003ewithAdminTableTopExtraTablenavs(array)\n-\u003ewithAdminTableBottomExtraTablenavs(array)\n```\n\n##### _View Page_\nSet up a view page, for the Admin Table.  \nDefault: `null`\n\nThis one takes an instance of the `ViewPage` class.  \nThe `ViewPage` can be customized, with different things. To se a list of all the settings, see [ViewPage](#viewpage).\n\n```php\n-\u003ewithViewPage()\n```\n\n##### _ACF Create Page_\nSet up an ACF create page, for the Admin Table.  \nDefault: `null`\n\nThis one takes an instance of the `AcfCreatePage` class.  \nThe `AcfCreatePage` can be customized, with different things. To se a list of all the settings, see [AcfCreatePage](#acfcreatepage).\n\n```php\n-\u003ewithAcfCreatePage()\n```\n\n##### _ACF Edit Page_\nSet up an ACF edit page, for the Admin Table.  \nDefault: `null`\n\nThis one takes an instance of the `AcfEditPage` class.  \nThe `AcfEditPage` can be customized, with different things. To se a list of all the settings, see [AcfEditPage](#acfeditpage).\n\n```php\n-\u003ewithAcfEditPage()\n```\n\n\n##### _Meta Boxes_\nRender meta boxes.  \nDefault: `null`\n\nThis one takes an array, of instances, of the `MetaBox` class.  \nThe `MetaBox` can be customized, with different things. To se a list of all the settings, see [MetaBox](#metabox).\n\n```php\n-\u003ewithMetaBoxes(array)\n```\n\n##### _Without Columns_\nSets the value as excluded columns, for the Admin Table.  \nDefault: `[]`\n\nEach item in the array, is the slug on the column.\n\n```php\n-\u003ewithoutColumns(array)\n```\n\n##### _Parent Slug_\nSets the value as parent slug, for the Model Page.  \nDefault: `null`\n\n```php\n-\u003emakeSubMenu(string)\n```\n\n##### _Removable_\nAdd a removable option.  \nDefault: `false`\n\n```php\n-\u003emakeRemovable()\n```\n\n---\n\n### Column\nTo get an instance of a `Column`, use the wrapper method: `\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::column()`.  \nThe wrapper method has the following parameters:\n\n- `string $slug`\n\n##### _Title_\nSets the value to the column title.  \nDefault: `slug, with first letter uppercase`\n\n```php\n-\u003ewithTitle(string)\n```\n\n##### _Render_\nRender the `callback|string` in each row, for the specific column.  \nDefault: `output the value`  \nParameters in callback:\n- `$instance`\n- `ModelPage $modelPage`\n\n```php\n-\u003ewithRender(callback|string)\n```\n\n##### _Searchable_\nMakes the column searchable. It can take a `callback|string`, where it's possible to make own search, on a custom column, that isn't on the Eloquent model table.  \nDefault: `false`  \nParameters in callback:\n- `\\Illuminate\\Database\\Eloquent\\Builder $dataQuery`\n- `string $searchString`\n\n```php\n-\u003emakeSearchable(callback|string|null)\n```\n\n##### _Sortable_\nMakes the column sortable. It can take a `callback|string`, where it's possible to make own order, on a custom column, that isn't on the Eloquent model table.  \nDefault: `false`  \nParameters in callback:\n- `\\Illuminate\\Database\\Eloquent\\Builder $dataQuery`\n- `string $order`\n\n```php\n-\u003emakeSortable(callback|string|null)\n```\n\n---\n\n### RowAction\nTo get an instance of a `RowAction`, use the wrapper method: `\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::rowAction()`.  \nThe wrapper method has the following parameters:\n\n- `string $slug`\n- `callable|string $renderCallback`: Callback has the following parameters:\n  - `array $item`\n  - `ModelPage $modelPage`\n\n---\n\n### AdminTableView\nTo get an instance of a `AdminTableView`, use the wrapper method: `\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::adminTableView()`.  \nThe wrapper method has the following parameters:\n\n- `string $urlKey`\n- `null|string $urlValue`\n\n##### _Title_\nSets the value to the view title.  \nDefault: `urlKey, with first letter uppercase`\n\n```php\n-\u003ewithTitle(string)\n```\n\n##### _Count_\nSets the value to the view count.  \nDefault: `null`\n\n```php\n-\u003ewithCount(string)\n```\n\n##### _Count Callback_\nSets the callback value to the view count.  \nDefault: `null`\nParameters in callback:\n- `AdminTableView $view`\n\n```php\n-\u003ewithCountCallback(callback|string)\n```\n\n---\n\n### AdminTableExtraTablenav\nTo get an instance of a `AdminTableExtraTablenav`, use the wrapper method: `\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::adminTableExtraTablenav()`.  \nThe wrapper method has the following parameters:\n\n- `callback|string $renderCallback`\n\n---\n\n### ViewPage\nTo get an instance of a `ViewPage`, use the wrapper method: `\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::viewPage()`.\n\n##### _Render_\nRender the `callback|string`, on the view page.  \nDefault: `shows a table, with all data in a \u003ctable\u003e`  \nParameters in callback:\n- `array $data`\n- `$currentModelPage`\n\n```php\n-\u003ewithRender(callback|string)\n```\n\n##### _Capability_\nSets the value to the capability.  \nDefault: `ModelPage::capability`\n\n```php\n-\u003ewithCapability(string)\n```\n\n##### _Hide default view_\nHide the default view.  \nDefault: `true`\n\n```php\n-\u003ehideDefaultView()\n```\n\n---\n\n### AcfCreatePage\nTo get an instance of a `AcfCreatePage`, use the wrapper method: `\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::acfCreatePage()`.\n\nTo make this work, it's needed to create an ACF group, that has the fields, like the Eloquent Model, that can be created.  \nUnder the ACF group locations, there is a new rule called **Eloquent Model**, that should be chosen to show the ACF group on the create page.\n\n##### _Save Callback_\nCalls the `callback|string`, when a Model is updated, through ACF.  \nDefault: `null`  \nParameters in callback|string:\n\n- `$instance`\n- `$model`\n- `array $values`\n\n```php\n-\u003ewithSaveCallback(callback|string)\n```\n\n##### _Capability_\nSets the value to the capability.  \nDefault: `ModelPage::capability`\n\n```php\n-\u003ewithCapability(string)\n```\n\n---\n\n### AcfEditPage\nTo get an instance of a `AcfEditPage`, use the wrapper method: `\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::acfEditPage()`.\n\nTo make this work, it's needed to create an ACF group, that has the fields, like the Eloquent Model, that can be edited.  \nUnder the ACF group locations, there is a new rule called **Eloquent Model**, that should be chosen to show the ACF group on the edit page.\n\n\n##### _Load Field Callbacks_\nCalls the `AcfLoadField` `callback|string`, when a field, on the Model, is loaded.  \nDefault: `[]`\n\nThis one takes an array of the `AcfLoadField` classes.  \nThe `AcfLoadField` can be customized, with different things. To se a list of all the settings, see [AcfLoadField](#acfloadfield).\n\n```php\n-\u003ewithLoadFieldCallbacks([])\n```\n\n##### _Save Callback_\nCalls the `callback|string`, when a Model is updated, through ACF.  \nDefault: `null`  \nParameters in callback|string:\n\n- `int|null $modelId`\n- `$model`\n- `array $values`\n\n```php\n-\u003ewithSaveCallback(callback|string)\n```\n\n##### _Capability_\nSets the value to the capability.  \nDefault: `ModelPage::capability`\n\n```php\n-\u003ewithCapability(string)\n```\n\n---\n\n### AcfLoadField\nTo get an instance of a `AcfLoadField`, use the wrapper method: `\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::acfLoadField()`.  \nThe wrapper method has the following parameters:\n\n- `string $slug`\n- `callable|string $renderCallback`: Callback has the following parameters:\n  - `mixed $return`\n  - `string $slug`\n  - `int $modelId`\n  - `$model`\n\n---\n\n### MetaBox\nTo get an instance of a MetaBox, use the wrapper method: `\\Morningtrain\\WP\\DatabaseModelAdminUi\\ModelUI::metaBox()`.  \nThe wrapper method has the following parameters:\n\n- `string $slug`\n- `callable|string $renderCallback`: Callback has the following parameters:\n  - `int|null $modelId`\n  - `$model`\n\n\n##### _Title_\nSets the value to the meta box title.  \nDefault: `slug, with first letter uppercase`\n\n```php\n-\u003ewithTitle(string)\n```\n\n##### _High Priority_\nSets the priority to high.\nDefault: `default`\n\n```php\n-\u003ewithHighPriority()\n```\n\n##### _Core Priority_\nSets the priority to core.\nDefault: `default`\n\n```php\n-\u003ewithCorePriority()\n```\n\n##### _Low Priority_\nSets the priority to low.\nDefault: `default`\n\n```php\n-\u003ewithLowPriority()\n```\n\n##### _Side Context_\nSets the context to side.\nDefault: `normal`\n\n```php\n-\u003eonSideContext()\n```\n\n##### _On ACF Edit Page_\nSets the meta box to be rendered on Acf Edit Page.  \nDefault: `Admin Table`\n\n```php\n-\u003eonAcfEditPage()\n```\n\n\n## Contributing\n\nThank you for your interest in contributing to the project.\n\n\n### Bug Report\n\nIf you found a bug, we encourage you to make a pull request.\n\nTo add a bug report, create a new issue. Please remember to add a telling title, detailed description and how to reproduce the problem. \n\n\n### Support Questions\n\nWe do not provide support for this package.\n\n\n### Pull Requests\n\n1. Fork the Project\n2. Create your Feature Branch (git checkout -b feature/AmazingFeature)\n3. Commit your Changes (git commit -m 'Add some AmazingFeature')\n4. Push to the Branch (git push origin feature/AmazingFeature)\n5. Open a Pull Request\n\n\n## Credits\n\n- [Martin Schadegg Brønniche](https://github.com/mschadegg)\n- [Mathias Bærentsen](https://github.com/matbaek)\n- [All Contributors](../../contributors)\n\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n\n\n---\n\n\u003cdiv align=\"center\"\u003e\nDeveloped by \u003cbr\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://morningtrain.dk\" target=\"_blank\"\u003e\n\u003cimg src=\"https://morningtrain.dk/wp-content/themes/mtt-wordpress-theme/assets/img/logo-only-text.svg\" width=\"200\" alt=\"Morningtrain logo\"\u003e\n\u003c/a\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorning-train%2Fwp-database-model-admin-ui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorning-train%2Fwp-database-model-admin-ui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorning-train%2Fwp-database-model-admin-ui/lists"}