82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Models\UserVip;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Show;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
|
|
class UserVipController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(UserVip::with(['user', 'vip']), function (Grid $grid) {
|
|
|
|
$grid->model()->where('status', UserVip::STATUS_SUCCESS);
|
|
|
|
$grid->column('user.phone');
|
|
$grid->column('vip.name');
|
|
$grid->column('times')->display(function ($v) {
|
|
return data_get($v, 'text');
|
|
});
|
|
$grid->column('success_time');
|
|
$grid->column('created_at');
|
|
|
|
$grid->disableViewButton(false);
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->panel(false);
|
|
$filter->like('name')->width(3);
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, UserVip::with(['user', 'vip']), function (Show $show) {
|
|
$show->field('id');
|
|
$show->field('user_id');
|
|
$show->field('vip_id');
|
|
$show->field('times')->as(function ($v) {
|
|
return data_get($v, 'text');
|
|
});;
|
|
$show->field('success_time');
|
|
$show->field('created_at');
|
|
$show->field('updated_at');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new UserVip(), function (Form $form) {
|
|
$form->display('id');
|
|
$form->text('user_id');
|
|
$form->text('vip_id');
|
|
$form->text('times');
|
|
$form->text('success_time');
|
|
|
|
$form->display('created_at');
|
|
$form->display('updated_at');
|
|
});
|
|
}
|
|
}
|