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.
|
|
<?php
namespace App\Admin\Controllers;
use App\Models\OrderChanged;use Dcat\Admin\Form;use Dcat\Admin\Grid;use Dcat\Admin\Show;use Dcat\Admin\Http\Controllers\AdminController;use Dcat\Admin\Widgets\Card;use Illuminate\Support\Str;
class OrderChangedController extends AdminController{ /** * Make a grid builder. * * @return Grid */ protected function grid() { return Grid::make(new OrderChanged(), function (Grid $grid) { $grid->model()->orderBy('id', 'desc');
$grid->column('id')->sortable(); $grid->column('order_id');
$grid->column('state') ->using(admin_trans('order.options.state')) ->label([ 0 => 'primary', 1 => 'warning', 2 => 'success', 3 => 'danger', 4 => 'gray', ]);
$grid->column('receive_time');
$grid->column('receive_body') ->width('20%') ->display(fn($v) => e(Str::limit($v, 20))) ->modal(function (Grid\Displayers\Modal $modal) { $modal->title(admin_trans('order-notify.fields.push_body')); parse_str($this->push_body, $r); $html = '推送数据:<pre>'.e($this->push_body).'</pre><br/>PHP数组:<pre>'.var_export($r, true).'</pre>'; $card = new Card(null, $html); return $card->render(); });
$grid->column('created_at');
$grid->disableCreateButton(); $grid->disableEditButton(); $grid->disableDeleteButton(); $grid->disableBatchDelete();
$grid->filter(function (Grid\Filter $filter) { $filter->equal('order_id')->width(3);
}); }); }
/** * Make a show builder. * * @param mixed $id * * @return Show */ protected function detail($id) { return Show::make($id, new OrderChanged(), function (Show $show) { $show->disableEditButton(); $show->disableDeleteButton(); $show->field('id'); $show->field('order_id'); $show->field('state')->using(admin_trans('order.options.state')); $show->field('receive_time'); $show->field('receive_body')->unescape()->as(function ($v) { parse_str($v, $r); return '推送数据:<pre>'.e($v).'</pre><br/>PHP数组:<pre>'.var_export($r, true).'</pre>'; }); $show->field('created_at'); }); }
/** * Make a form builder. * * @return Form */ protected function form() { return Form::make(new OrderChanged(), function (Form $form) { $form->display('id'); }); }}
|