You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.3 KiB
95 lines
2.3 KiB
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Repositories\AdminSetting;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Layout\Content;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use function Symfony\Component\Translation\t;
|
|
|
|
class AdminSettingController extends AdminController
|
|
{
|
|
|
|
public function create(Content $content)
|
|
{
|
|
return $content->body(
|
|
Form::make(new AdminSetting(), function (Form $form) {
|
|
$form->text('slug')->disable(false);
|
|
$form->text('value');
|
|
|
|
$form->display('created_at');
|
|
$form->display('updated_at');
|
|
})
|
|
);
|
|
}
|
|
|
|
public function showOnenet(Content $content)
|
|
{
|
|
return $content
|
|
->translation($this->translation())
|
|
->title($this->title())
|
|
->description($this->description()['edit'] ?? trans('admin.edit'))
|
|
->body($this->form()->edit('onenet_api_key'));
|
|
}
|
|
|
|
public function editOnenet()
|
|
{
|
|
return $this->form()->update('onenet_api_key');
|
|
}
|
|
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(new AdminSetting(), function (Grid $grid) {
|
|
$grid->column('slug')->disable(true);
|
|
$grid->column('value');
|
|
$grid->column('created_at');
|
|
$grid->column('updated_at')->sortable();
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->equal('slug');
|
|
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new AdminSetting(), function (Show $show) {
|
|
$show->field('slug');
|
|
$show->field('value');
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new AdminSetting(), function (Form $form) {
|
|
$form->text('slug')->display(false);
|
|
$form->text('value');
|
|
|
|
$form->display('created_at')->display(false);;
|
|
$form->display('updated_at')->display(false);;
|
|
});
|
|
}
|
|
}
|
|
|