Download the PHP package morningtrain/wp-database-model-admin-ui without Composer
On this page you can find all versions of the php package morningtrain/wp-database-model-admin-ui. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download morningtrain/wp-database-model-admin-ui
More information about morningtrain/wp-database-model-admin-ui
Files in morningtrain/wp-database-model-admin-ui
Package wp-database-model-admin-ui
Short Description Autogenerated Wordpress Admin Tables, for Eloquent Models
License MIT
Informations about the package wp-database-model-admin-ui
Morningtrain\WP\DatabaseModelAdminUi
Autogenerated Wordpress Admin Tables, for Eloquent Models.
Table of Contents
- Introduction
- Getting Started
- Installation
- Dependencies
- Usage
- Initializing package
- Use for an Eloquent Model
- Classes
- ModelPage
- Column
- RowAction
- AdminTableView
- AdminTableExtraTablenav
- ViewPage
- AcfEditPage
- AcfLoadField
- MetaBox
- Contributing
- Bug Report
- Support Questions
- Pull Requests
- Credits
- License
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
To get started install the package as described below in Installation.
To use the tool have a look at Usage
Installation
Install with composer
Dependencies
Usage
Initializing package
Initialize \Morningtrain\WP\DatabaseModelAdminUi\ModelUI
with the folder, where all the Eloquent Models is located.
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:
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.
Classes
ModelPage
Page Title
Sets the value to the page title, for the Admin Table.
Default: Admin Table
Menu Title
Sets the value to the menu title, for the Admin Table.
Default: Admin Table
Capability
Sets the value, that the user needs, for viewing the Admin Table.
Default: manage_options
Icon Url
Sets the value for the Admin Table admin menu icon.
Default: empty value
Position
Sets the value for the Admin Table admin menu position.
Default: null
Search button text
Sets the value for the Admin Table search button text.
Default: __('Search')
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.
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.
Modify Query Callback
Return the callback|string
modified \Illuminate\Database\Eloquent\Builder
.
Default: null
Parameters in callback:
\Illuminate\Database\Eloquent\Builder $query
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.
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.
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.
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.
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.
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.
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.
Without Columns
Sets the value as excluded columns, for the Admin Table.
Default: []
Each item in the array, is the slug on the column.
Parent Slug
Sets the value as parent slug, for the Model Page.
Default: null
Removable
Add a removable option.
Default: false
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
Sets the value to the column title.
Default: slug, with first letter uppercase
Render
Render the callback|string
in each row, for the specific column.
Default: output the value
Parameters in callback:
$instance
ModelPage $modelPage
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
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
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
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
Sets the value to the view title.
Default: urlKey, with first letter uppercase
Count
Sets the value to the view count.
Default: null
Count Callback
Sets the callback value to the view count.
Default: null
Parameters in callback:
AdminTableView $view
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
To get an instance of a ViewPage
, use the wrapper method: \Morningtrain\WP\DatabaseModelAdminUi\ModelUI::viewPage()
.
Render
Render the callback|string
, on the view page.
Default: shows a table, with all data in a <table>
Parameters in callback:
array $data
$currentModelPage
Capability
Sets the value to the capability.
Default: ModelPage::capability
Hide default view
Hide the default view.
Default: true
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
Calls the callback|string
, when a Model is updated, through ACF.
Default: null
Parameters in callback|string:
$instance
$model
array $values
Capability
Sets the value to the capability.
Default: ModelPage::capability
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
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.
Save Callback
Calls the callback|string
, when a Model is updated, through ACF.
Default: null
Parameters in callback|string:
int|null $modelId
$model
array $values
Capability
Sets the value to the capability.
Default: ModelPage::capability
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
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
Sets the value to the meta box title.
Default: slug, with first letter uppercase
High Priority
Sets the priority to high.
Default: default
Core Priority
Sets the priority to core.
Default: default
Low Priority
Sets the priority to low.
Default: default
Side Context
Sets the context to side.
Default: normal
On ACF Edit Page
Sets the meta box to be rendered on Acf Edit Page.
Default: Admin Table
Contributing
Thank you for your interest in contributing to the project.
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
We do not provide support for this package.
Pull Requests
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request
Credits
- Martin Schadegg Brønniche
- Mathias Bærentsen
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of wp-database-model-admin-ui with dependencies
morningtrain/php-loader Version ^0.3
morningtrain/wp-view Version ^0.4.1
morningtrain/wp-hooks Version ^0.3.2