86 lines
2.3 KiB
PHP
86 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Repositories\ProductBuynote;
|
|
use Dcat\Admin\Admin;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use Dcat\Admin\Show;
|
|
|
|
class ProductBuynoteController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(new ProductBuynote(), function (Grid $grid) {
|
|
$grid->column('id')->sortable();
|
|
$grid->column('name');
|
|
// $grid->column('content');
|
|
$grid->column('created_at')->sortable();
|
|
|
|
//排序
|
|
$grid->model()->orderBy('created_at', 'desc');
|
|
|
|
/** 操作 **/
|
|
//新增
|
|
if (Admin::user()->can('dcat.admin.product_buynotes.create')) {
|
|
$grid->disableCreateButton(false);
|
|
// $grid->enableDialogCreate();
|
|
}
|
|
|
|
//删除以及自定义操作
|
|
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
|
$actions->disableEdit(Admin::user()->cannot('dcat.admin.product_buynotes.edit'));
|
|
$actions->disableDelete(Admin::user()->cannot('dcat.admin.product_buynotes.destroy'));
|
|
});
|
|
|
|
/** 查询 **/
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->panel();
|
|
$filter->like('name')->width(3);
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new ProductBuynote(), function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('name');
|
|
$show->field('content');
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new ProductBuynote(), function (Form $form) {
|
|
$form->display('id');
|
|
$form->text('name')->required();
|
|
$form->editor('content');
|
|
|
|
$form->display('created_at');
|
|
$form->display('updated_at');
|
|
});
|
|
}
|
|
}
|