12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace App\Admin\Controllers;
- use App\Models\Giveaway;
- use Dcat\Admin\Form;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Show;
- use Dcat\Admin\Http\Controllers\AdminController;
- class GiveawayController extends AdminController
- {
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- return Grid::make(new Giveaway(), function (Grid $grid) {
- $grid->model()->with(['user','order','buyUser'])->orderByDesc('id');
- $grid->column('id')->sortable();
- $grid->column('user.name','购买者昵称');
- $grid->column('user.avatar','购买者头像')->image('',40,40);
- $grid->column('buyUser.name','推荐人昵称');
- $grid->column('buyUser.avatar','推荐人头像')->image('',40,40);
- $grid->column('order.order','订单号');
- $grid->column('title');
- $grid->column('amount','佣金');
- $grid->column('order.amount','支付金额');
- $grid->column('created_at');
- $grid->column('updated_at')->sortable();
- $grid->filter(function (Grid\Filter $filter) {
- $filter->panel();
- $filter->between('created_at')->datetime();
- });
- $grid->disableViewButton();
- $grid->disableCreateButton();
- $grid->disableDeleteButton();
- $grid->disableEditButton();
- });
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- *
- * @return Show
- */
- protected function detail($id)
- {
- return Show::make($id, new Giveaway(), function (Show $show) {
- $show->field('id');
- $show->field('user_id');
- $show->field('purchaser_user_id');
- $show->field('title');
- $show->field('amount');
- $show->field('order_id');
- $show->field('created_at');
- $show->field('updated_at');
- });
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- return Form::make(new Giveaway(), function (Form $form) {
- $form->display('id');
- $form->text('user_id');
- $form->text('purchaser_user_id');
- $form->text('title');
- $form->text('amount');
- $form->text('order_id');
- $form->display('created_at');
- $form->display('updated_at');
- });
- }
- }
|