78 lines
1.9 KiB
PHP
Executable File
78 lines
1.9 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Repositories\Contact;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
|
|
class ContactController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(new Contact(), function (Grid $grid) {
|
|
$grid->column('id')->sortable();
|
|
$grid->column('type')->using(\App\Models\Contact::TYPE);
|
|
$grid->column('name');
|
|
$grid->column('mobile');
|
|
$grid->column('content');
|
|
$grid->column('created_at')->sortable();
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->equal('mobile');
|
|
});
|
|
$grid->model()->orderBy('id', 'desc');
|
|
|
|
$grid->disableEditButton();
|
|
$grid->disableCreateButton();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new Contact(), function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('type')->using(\App\Models\Contact::TYPE);;
|
|
$show->field('name');
|
|
$show->field('mobile');
|
|
$show->field('content');
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
$show->disableEditButton();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new Contact(), function (Form $form) {
|
|
$form->display('id');
|
|
$form->text('type');
|
|
$form->text('name');
|
|
$form->text('mobile');
|
|
$form->text('content');
|
|
|
|
$form->display('created_at');
|
|
$form->display('updated_at');
|
|
});
|
|
}
|
|
}
|