framework agnostic admin panel.
trying to make it as minimal as possible. it allows you to create multiple pages with different types (table, form). without intervening much with your code base.
ps: you still need to setup your routes, the authentication etc...
We allow multiple type of responses, as a default we used php views, but we figured for laravel users as an example, would use blade instead, so one possible solution is to create a different Renderer.
For now we have two default Renderers:
DefaultRenderer this just returns an array as outputJsonRenderer this returns json outputTo create a Renderer make it extends AecodesAdminPanelResponsesRenderer. then add it to config.
ps: widgets implements Widget interface.
config/panel.php as a starting point.Dashboard class, make sure to pass the config as an array.$config = require './config/panel.php';
AecodesAdminPanelDashboard::setup($config);Panel class$name & $description of the panel (visible on the page).query method that returns the array of data.function query(): array {
// get data from database.
return Page::all()->toArray();
}render method that returns an array of widgets.function render(): array {
return [
Table::make([
// (label, name) both are optional
TD::make('#', 'id'),
// it's also possible to use Table::column
Table::column('Title', 'title'),
])
// ...
];
}function render(): array {
return [
Form::make([
Input::make('title')->title('Title'),
// form submit
Action::button('Save'),
])
->action('#')
->method('post'),
// ...
];
}// callback for some route
public function index() {
// PagesTable extends Panel
return (new Response(new PagesTable))->render();
}when extending the Panel class you can specify the $layout property.
this doesn't ship with a view layer. you can use the default (soon) views packages.
The default config is:
return [
// current renderer.
'renderer' => 'default',
// add new renderer here.
'renderers' => [
'json' => AecodesAdminPanelResponsesJsonRenderer::class,
'default' => AecodesAdminPanelResponsesDefaultRenderer::class,
],
// default classes for button and a tag.
'classes' => [
'link' => '',
'button' => '',
],
// global menus, can be and array or callback
'menu' => function () {
return [];
},
// input old value.
'old_value' => function ($name, $default) {
return $default;
},
// global errors (i.e: validation errors)
'errors' => function () {
return [];
}
];