优化活动列表
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Admin\Controllers\Activity;
|
||||
|
||||
use App\Admin\Renderable\Activity\Grants;
|
||||
use App\Admin\Renderable\Activity\Verifications;
|
||||
use App\Models\Activity;
|
||||
use App\Models\ActivityRule;
|
||||
use App\Models\User;
|
||||
@@ -18,7 +20,7 @@ class IndexController extends AdminController
|
||||
protected function grid(): Grid
|
||||
{
|
||||
$grid = new Grid(new Activity);
|
||||
$grid->model()->withCount('coupons');
|
||||
$grid->model()->with(['rule', 'grants', 'verifications'])->withCount('coupons');
|
||||
|
||||
$grid->actions(function ($actions) {
|
||||
$actions->disableView();
|
||||
@@ -59,21 +61,15 @@ class IndexController extends AdminController
|
||||
$grid->column('days', '延期(天)');
|
||||
$grid->column('rule.full', '满足金额');
|
||||
$grid->column('rule.take', '扣除金额');
|
||||
$grid->column('发券渠道')
|
||||
->display(function () {
|
||||
return $this->grants->pluck('user_nickname');
|
||||
})
|
||||
->label()
|
||||
->width(350)
|
||||
->hide();
|
||||
|
||||
$grid->column('核券渠道')
|
||||
->display(function () {
|
||||
return $this->verifications->pluck('user_nickname');
|
||||
})
|
||||
->label()
|
||||
->width(350)
|
||||
->hide();
|
||||
$grid->column('发券渠道')->display(function ($title, $column) {
|
||||
return '查看';
|
||||
})->modal(Grants::class);
|
||||
|
||||
$grid->column('核券渠道')->display(function ($title, $column) {
|
||||
return '查看';
|
||||
})->modal(Verifications::class);
|
||||
|
||||
|
||||
$grid->column('开始时间')->display(function () {
|
||||
return $this->type == Activity::TYPE_SCOPE ? $this->start_at->format('Y-m-d') : '---';
|
||||
@@ -94,6 +90,7 @@ class IndexController extends AdminController
|
||||
|
||||
/**
|
||||
* Make a form builder.
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
protected function form(): Form
|
||||
@@ -222,11 +219,11 @@ class IndexController extends AdminController
|
||||
}
|
||||
|
||||
if (request()->start) {
|
||||
$form->start_at = $form->start_at . ' 00:00:01';
|
||||
$form->start_at = $form->start_at.' 00:00:01';
|
||||
}
|
||||
|
||||
if (request()->end_at) {
|
||||
$form->end_at = $form->end_at . ' 23:59:59';
|
||||
$form->end_at = $form->end_at.' 23:59:59';
|
||||
}
|
||||
|
||||
$shops = isset(request()->shops) ? array_filter(request()->shops['user_id']) : [];
|
||||
@@ -274,7 +271,7 @@ class IndexController extends AdminController
|
||||
|
||||
$shops = isset(request()->shops) ? array_filter(request()->shops['user_id']) : [];
|
||||
|
||||
if (!empty($shops)) {
|
||||
if (! empty($shops)) {
|
||||
//设置核销网点
|
||||
$users = [];
|
||||
foreach ($form->shops['user_id'] as $key => $user_id) {
|
||||
|
||||
@@ -18,9 +18,11 @@ class Grants implements Renderable
|
||||
'nickname' => $info->user_nickname,
|
||||
];
|
||||
});
|
||||
dd($items->toArray());
|
||||
|
||||
return new Table(['Id', '渠道'], $items->toArray());
|
||||
$table = new Table(['Id', '渠道'], $items->toArray());
|
||||
|
||||
return $table->render();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
28
app/Admin/Renderable/Activity/Verifications.php
Normal file
28
app/Admin/Renderable/Activity/Verifications.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Renderable\Activity;
|
||||
|
||||
use App\Models\Activity;
|
||||
use Encore\Admin\Widgets\Table;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
|
||||
class Verifications implements Renderable
|
||||
{
|
||||
|
||||
public function render($key = null)
|
||||
{
|
||||
$activity = Activity::find($key);
|
||||
$items = $activity->verifications->map(function ($info) {
|
||||
return [
|
||||
'id' => $info->id,
|
||||
'nickname' => $info->user_nickname,
|
||||
];
|
||||
});
|
||||
|
||||
$table = new Table(['Id', '渠道'], $items->toArray());
|
||||
|
||||
return $table->render();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user