82 lines
2.1 KiB
PHP
82 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Admin\Repositories\PointsLog;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use Dcat\Admin\Show;
|
|
|
|
class PointsLogController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
$builder = PointsLog::with('user');
|
|
return Grid::make($builder, function (Grid $grid) {
|
|
// $grid->column('id')->sortable();
|
|
$grid->column('user.phone')->copyable();
|
|
$grid->column('desc');
|
|
// $grid->column('type');
|
|
$grid->column('points');
|
|
$grid->column('old_points');
|
|
|
|
$grid->column('created_at')->sortable();
|
|
$grid->model()->orderBy('created_at', 'desc');
|
|
// $grid->column('updated_at')->sortable();
|
|
|
|
$grid->disableActions();
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->panel(false);
|
|
$filter->equal('user.phone')->width(3);
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new PointsLog(), function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('user_id');
|
|
$show->field('type');
|
|
$show->field('points');
|
|
$show->field('old_points');
|
|
$show->field('desc');
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new PointsLog(), function (Form $form) {
|
|
$form->display('id');
|
|
$form->text('user_id');
|
|
$form->text('type');
|
|
$form->text('points');
|
|
$form->text('old_points');
|
|
$form->text('desc');
|
|
|
|
$form->display('created_at');
|
|
$form->display('updated_at');
|
|
});
|
|
}
|
|
}
|