PHPackages                             morningtrain/wp-database-model-admin-ui - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. morningtrain/wp-database-model-admin-ui

ActiveLibrary[Database &amp; ORM](/categories/database)

morningtrain/wp-database-model-admin-ui
=======================================

Autogenerated Wordpress Admin Tables, for Eloquent Models

v0.5.2(2y ago)06051MITPHP

Since Feb 3Pushed 2y ago3 watchersCompare

[ Source](https://github.com/Morning-Train/wp-database-model-admin-ui)[ Packagist](https://packagist.org/packages/morningtrain/wp-database-model-admin-ui)[ RSS](/packages/morningtrain-wp-database-model-admin-ui/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (17)Used By (0)

Morningtrain\\WP\\DatabaseModelAdminUi
======================================

[](#morningtrainwpdatabasemodeladminui)

Autogenerated Wordpress Admin Tables, for Eloquent Models.

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Getting Started](#getting-started)
    - [Installation](#installation)
- [Dependencies](#dependencies)
- [Usage](#usage)
    - [Initializing package](#initializing-package)
    - [Use for an Eloquent Model](#use-for-an-eloquent-model)
- [Classes](#classes)
    - [ModelPage](#modelpage)
    - [Column](#column)
    - [RowAction](#rowaction)
    - [AdminTableView](#admintableview)
    - [AdminTableExtraTablenav](#admintableextratablenav)
    - [ViewPage](#viewpage)
    - [AcfEditPage](#acfeditpage)
    - [AcfLoadField](#acfloadfield)
    - [MetaBox](#metabox)
- [Contributing](#contributing)
    - [Bug Report](#bug-report)
    - [Support Questions](#support-questions)
    - [Pull Requests](#pull-requests)
- [Credits](#credits)
- [License](#license)

Introduction
------------

[](#introduction)

Make it easy, to create a WordPress Admin Table CRUD.
**Overview**: Makes a WordPress Admin Table, with the data from the Eloquent Model.

**Create**: Allows to create a new instance of the Eloquent Model, from an ACF group.
**Read**: Make a view page, where the data from the instance is displayed.
**Update**: Allows to update an instance of the Eloquent Model, from an ACF group.
**Delete**: Allows to delete an instance of the Eloquent Model.

**IMPORTANT**:
You will need ACF (Advanced Custom Fields) to get the *Create* and *Update* parts to work.

Getting Started
---------------

[](#getting-started)

To get started install the package as described below in [Installation](#installation).

To use the tool have a look at [Usage](#usage)

### Installation

[](#installation)

Install with composer

```
composer require morningtrain/wp-database-model-admin-ui
```

Dependencies
------------

[](#dependencies)

- [morningtrain/php-loader](https://packagist.org/packages/morningtrain/php-loader)
- [morningtrain/wp-database](https://packagist.org/packages/morningtrain/wp-database)
- [morningtrain/wp-hooks](https://packagist.org/packages/morningtrain/wp-hooks)
- [morningtrain/wp-view](https://packagist.org/packages/morningtrain/wp-view)

Usage
-----

[](#usage)

### Initializing package

[](#initializing-package)

Initialize `\Morningtrain\WP\DatabaseModelAdminUi\ModelUI` with the folder, where all the Eloquent Models is located.

```
\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::setup(__DIR__ . "/app/Models");
```

### Use for an Eloquent Model

[](#use-for-an-eloquent-model)

When an Admin Table need to be show, for an Eloquent Model, this need to be register in.
To do this, on each Model class, there will be called a static method called `setupAdminUi`.
To start of, use `\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::modelPage()` method and give it a slug and an Eloquent Model class.
The wrapper method has the following parameters:

- `string $slug`
- `string $model`

When this is done, we need to register it. This is done by:

```
\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::modelPage(string, string)
    ->register();
```

This is all there is to get started with an Admin Table overview.
This will show an Admin Table overview, with all it's columns.

The ModelPage can be customized, with different things. To se a list of all the settings, see [ModelPage](#modelpage).

Classes
-------

[](#classes)

### ModelPage

[](#modelpage)

##### *Page Title*

[](#page-title)

Sets the value to the page title, for the Admin Table.
Default: `Admin Table`

```
->withPageTitle(string)
```

##### *Menu Title*

[](#menu-title)

Sets the value to the menu title, for the Admin Table.
Default: `Admin Table`

```
->withMenuTitle(string)
```

##### *Capability*

[](#capability)

Sets the value, that the user needs, for viewing the Admin Table.
Default: `manage_options`

```
->withCapability(string)
```

##### *Icon Url*

[](#icon-url)

Sets the value for the Admin Table admin menu icon.
Default: ***empty value***

```
->withIconUrl(string)
```

##### *Position*

[](#position)

Sets the value for the Admin Table admin menu position.
Default: `null`

```
->withPosition(int)
```

##### *Search button text*

[](#search-button-text)

Sets the value for the Admin Table search button text.
Default: `__('Search')`

```
->withSearchButtonText(string)
```

##### *Columns*

[](#columns)

Sets the value as columns, for the Admin Table.
Default: `all columns on the Model`

This one takes an array of the `Column` classes.
The `Column` can be customized, with different things. To se a list of all the settings, see [Column](#column).

```
->withColumns(array)
```

##### *Row Actions*

[](#row-actions)

Sets the value as row actions, for the Admin Table.
Default: `[]`

If method `->withViewPage()` is in use, it will add a default **View** action to each row.
If method `->withAcfEditPage()` is in use, it will add a default **Edit** action to each row.
If method `->makeRemovable()` is in use, it will add a default **Delete** action to each row.

This one takes an array of the `RowAction` classes.
The `RowAction` can be customized, with different things. To se a list of all the settings, see [RowAction](#rowaction).

```
->withRowActions(array)
```

##### *Modify Query Callback*

[](#modify-query-callback)

Return the `callback|string` modified `\Illuminate\Database\Eloquent\Builder`.
Default: `null`Parameters in callback:

- `\Illuminate\Database\Eloquent\Builder $query`

```
->withModifyQueryCallback(\Illuminate\Database\Eloquent\Builder)
```

##### *Admin Table Views*

[](#admin-table-views)

Set up the Admin Table views.
Default: `[]`

This one takes an array of the `AdminTableViews` classes.
The `AdminTableViews` can be customized, with different things. To se a list of all the settings, see [AdminTableViews](#admintableview).

```
->withAdminTableViews(array)
```

You can also add views by using the `->addAdminTableViewsCallback()` method instead. This should be used when having dynamic views to avoid using resources when not necessary.

Return the an array array of `AdminTableViews` instances.
Default: `null`
Parameters in callback:

- `ModelPage $modelPage`

The `AdminTableViews` can be customized, with different things. To se a list of all the settings, see [AdminTableViews](#admintableview).

```
->addAdminTableViewsCallback(callback)
```

##### *Admin Table Extra Tablenavns*

[](#admin-table-extra-tablenavns)

Set up the Admin Table extra tablenavns.
This one is split up into two methods, to have one for the top and one for the bottom.
Default: `[]`

Both methods takes an array of the `AdminTableExtraTablenav` classes.
The `AdminTableExtraTablenav` can be customized, with different things. To se a list of all the settings, see [AdminTableExtraTablenav](#admintableextratablenav).

```
->withAdminTableTopExtraTablenavs(array)
->withAdminTableBottomExtraTablenavs(array)
```

##### *View Page*

[](#view-page)

Set up a view page, for the Admin Table.
Default: `null`

This one takes an instance of the `ViewPage` class.
The `ViewPage` can be customized, with different things. To se a list of all the settings, see [ViewPage](#viewpage).

```
->withViewPage()
```

##### *ACF Create Page*

[](#acf-create-page)

Set up an ACF create page, for the Admin Table.
Default: `null`

This one takes an instance of the `AcfCreatePage` class.
The `AcfCreatePage` can be customized, with different things. To se a list of all the settings, see [AcfCreatePage](#acfcreatepage).

```
->withAcfCreatePage()
```

##### *ACF Edit Page*

[](#acf-edit-page)

Set up an ACF edit page, for the Admin Table.
Default: `null`

This one takes an instance of the `AcfEditPage` class.
The `AcfEditPage` can be customized, with different things. To se a list of all the settings, see [AcfEditPage](#acfeditpage).

```
->withAcfEditPage()
```

##### *Meta Boxes*

[](#meta-boxes)

Render meta boxes.
Default: `null`

This one takes an array, of instances, of the `MetaBox` class.
The `MetaBox` can be customized, with different things. To se a list of all the settings, see [MetaBox](#metabox).

```
->withMetaBoxes(array)
```

##### *Without Columns*

[](#without-columns)

Sets the value as excluded columns, for the Admin Table.
Default: `[]`

Each item in the array, is the slug on the column.

```
->withoutColumns(array)
```

##### *Parent Slug*

[](#parent-slug)

Sets the value as parent slug, for the Model Page.
Default: `null`

```
->makeSubMenu(string)
```

##### *Removable*

[](#removable)

Add a removable option.
Default: `false`

```
->makeRemovable()
```

---

### Column

[](#column)

To get an instance of a `Column`, use the wrapper method: `\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::column()`.
The wrapper method has the following parameters:

- `string $slug`

##### *Title*

[](#title)

Sets the value to the column title.
Default: `slug, with first letter uppercase`

```
->withTitle(string)
```

##### *Render*

[](#render)

Render the `callback|string` in each row, for the specific column.
Default: `output the value`
Parameters in callback:

- `$instance`
- `ModelPage $modelPage`

```
->withRender(callback|string)
```

##### *Searchable*

[](#searchable)

Makes 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.
Default: `false`
Parameters in callback:

- `\Illuminate\Database\Eloquent\Builder $dataQuery`
- `string $searchString`

```
->makeSearchable(callback|string|null)
```

##### *Sortable*

[](#sortable)

Makes 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.
Default: `false`
Parameters in callback:

- `\Illuminate\Database\Eloquent\Builder $dataQuery`
- `string $order`

```
->makeSortable(callback|string|null)
```

---

### RowAction

[](#rowaction)

To get an instance of a `RowAction`, use the wrapper method: `\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::rowAction()`.
The wrapper method has the following parameters:

- `string $slug`
- `callable|string $renderCallback`: Callback has the following parameters:
    - `array $item`
    - `ModelPage $modelPage`

---

### AdminTableView

[](#admintableview)

To get an instance of a `AdminTableView`, use the wrapper method: `\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::adminTableView()`.
The wrapper method has the following parameters:

- `string $urlKey`
- `null|string $urlValue`

##### *Title*

[](#title-1)

Sets the value to the view title.
Default: `urlKey, with first letter uppercase`

```
->withTitle(string)
```

##### *Count*

[](#count)

Sets the value to the view count.
Default: `null`

```
->withCount(string)
```

##### *Count Callback*

[](#count-callback)

Sets the callback value to the view count.
Default: `null`Parameters in callback:

- `AdminTableView $view`

```
->withCountCallback(callback|string)
```

---

### AdminTableExtraTablenav

[](#admintableextratablenav)

To get an instance of a `AdminTableExtraTablenav`, use the wrapper method: `\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::adminTableExtraTablenav()`.
The wrapper method has the following parameters:

- `callback|string $renderCallback`

---

### ViewPage

[](#viewpage)

To get an instance of a `ViewPage`, use the wrapper method: `\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::viewPage()`.

##### *Render*

[](#render-1)

Render the `callback|string`, on the view page.
Default: `shows a table, with all data in a `
Parameters in callback:

- `array $data`
- `$currentModelPage`

```
->withRender(callback|string)
```

##### *Capability*

[](#capability-1)

Sets the value to the capability.
Default: `ModelPage::capability`

```
->withCapability(string)
```

##### *Hide default view*

[](#hide-default-view)

Hide the default view.
Default: `true`

```
->hideDefaultView()
```

---

### AcfCreatePage

[](#acfcreatepage)

To get an instance of a `AcfCreatePage`, use the wrapper method: `\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::acfCreatePage()`.

To make this work, it's needed to create an ACF group, that has the fields, like the Eloquent Model, that can be created.
Under 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.

##### *Save Callback*

[](#save-callback)

Calls the `callback|string`, when a Model is updated, through ACF.
Default: `null`
Parameters in callback|string:

- `$instance`
- `$model`
- `array $values`

```
->withSaveCallback(callback|string)
```

##### *Capability*

[](#capability-2)

Sets the value to the capability.
Default: `ModelPage::capability`

```
->withCapability(string)
```

---

### AcfEditPage

[](#acfeditpage)

To get an instance of a `AcfEditPage`, use the wrapper method: `\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::acfEditPage()`.

To make this work, it's needed to create an ACF group, that has the fields, like the Eloquent Model, that can be edited.
Under 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.

##### *Load Field Callbacks*

[](#load-field-callbacks)

Calls the `AcfLoadField` `callback|string`, when a field, on the Model, is loaded.
Default: `[]`

This one takes an array of the `AcfLoadField` classes.
The `AcfLoadField` can be customized, with different things. To se a list of all the settings, see [AcfLoadField](#acfloadfield).

```
->withLoadFieldCallbacks([])
```

##### *Save Callback*

[](#save-callback-1)

Calls the `callback|string`, when a Model is updated, through ACF.
Default: `null`
Parameters in callback|string:

- `int|null $modelId`
- `$model`
- `array $values`

```
->withSaveCallback(callback|string)
```

##### *Capability*

[](#capability-3)

Sets the value to the capability.
Default: `ModelPage::capability`

```
->withCapability(string)
```

---

### AcfLoadField

[](#acfloadfield)

To get an instance of a `AcfLoadField`, use the wrapper method: `\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::acfLoadField()`.
The wrapper method has the following parameters:

- `string $slug`
- `callable|string $renderCallback`: Callback has the following parameters:
    - `mixed $return`
    - `string $slug`
    - `int $modelId`
    - `$model`

---

### MetaBox

[](#metabox)

To get an instance of a MetaBox, use the wrapper method: `\Morningtrain\WP\DatabaseModelAdminUi\ModelUI::metaBox()`.
The wrapper method has the following parameters:

- `string $slug`
- `callable|string $renderCallback`: Callback has the following parameters:
    - `int|null $modelId`
    - `$model`

##### *Title*

[](#title-2)

Sets the value to the meta box title.
Default: `slug, with first letter uppercase`

```
->withTitle(string)
```

##### *High Priority*

[](#high-priority)

Sets the priority to high. Default: `default`

```
->withHighPriority()
```

##### *Core Priority*

[](#core-priority)

Sets the priority to core. Default: `default`

```
->withCorePriority()
```

##### *Low Priority*

[](#low-priority)

Sets the priority to low. Default: `default`

```
->withLowPriority()
```

##### *Side Context*

[](#side-context)

Sets the context to side. Default: `normal`

```
->onSideContext()
```

##### *On ACF Edit Page*

[](#on-acf-edit-page)

Sets the meta box to be rendered on Acf Edit Page.
Default: `Admin Table`

```
->onAcfEditPage()
```

Contributing
------------

[](#contributing)

Thank you for your interest in contributing to the project.

### Bug Report

[](#bug-report)

If you found a bug, we encourage you to make a pull request.

To add a bug report, create a new issue. Please remember to add a telling title, detailed description and how to reproduce the problem.

### Support Questions

[](#support-questions)

We do not provide support for this package.

### Pull Requests

[](#pull-requests)

1. Fork the Project
2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
3. Commit your Changes (git commit -m 'Add some AmazingFeature')
4. Push to the Branch (git push origin feature/AmazingFeature)
5. Open a Pull Request

Credits
-------

[](#credits)

- [Martin Schadegg Brønniche](https://github.com/mschadegg)
- [Mathias Bærentsen](https://github.com/matbaek)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

---

Developed by

[![Morningtrain logo](https://camo.githubusercontent.com/e5c33559f0458f056816ab1a75dc9fe3bbd5a141e5d8630d85ec32fa45c01526/68747470733a2f2f6d6f726e696e67747261696e2e646b2f77702d636f6e74656e742f7468656d65732f6d74742d776f726470726573732d7468656d652f6173736574732f696d672f6c6f676f2d6f6e6c792d746578742e737667)](https://morningtrain.dk)

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Recently: every ~33 days

Total

16

Last Release

921d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/278725?v=4)[morningtrain](/maintainers/morningtrain)[@morningtrain](https://github.com/morningtrain)

---

Top Contributors

[![matbaek](https://avatars.githubusercontent.com/u/2310644?v=4)](https://github.com/matbaek "matbaek (195 commits)")[![mschadegg](https://avatars.githubusercontent.com/u/11231039?v=4)](https://github.com/mschadegg "mschadegg (24 commits)")

---

Tags

databaseeloquentphpwordpresswp

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/morningtrain-wp-database-model-admin-ui/health.svg)

```
[![Health](https://phpackages.com/badges/morningtrain-wp-database-model-admin-ui/health.svg)](https://phpackages.com/packages/morningtrain-wp-database-model-admin-ui)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
