46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Actions\Grid;
|
|
|
|
use App\Enums\DrawLogStatus;
|
|
use App\Models\DrawLog;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Illuminate\Http\Request;
|
|
|
|
class DrawLogComplete extends RowAction
|
|
{
|
|
protected $title = '<i class="feather icon-navigation grid-action-icon"></i> 发放奖品';
|
|
|
|
/**
|
|
* @param Model|Authenticatable|HasPermissions|null $user
|
|
*
|
|
* @return bool
|
|
*/
|
|
protected function authorize($user): bool
|
|
{
|
|
return $user->can('dcat.admin.draw_activities.log_complete');
|
|
}
|
|
|
|
// 确认弹窗信息
|
|
public function confirm()
|
|
{
|
|
return '您确定要发放中奖奖品吗?';
|
|
}
|
|
|
|
// 处理请求
|
|
public function handle(Request $request)
|
|
{
|
|
$drawLog = DrawLog::findOrFail($this->getKey());
|
|
|
|
if (! $drawLog->isPending()) {
|
|
return $this->response()->error('操作失败:中奖记录状态异常')->refresh();
|
|
}
|
|
|
|
$drawLog->update([
|
|
'status' => DrawLogStatus::Completed,
|
|
]);
|
|
|
|
return $this->response()->success('操作成功')->refresh();
|
|
}
|
|
}
|