43 lines
959 B
PHP
43 lines
959 B
PHP
<?php
|
|
|
|
namespace App\Admin\Actions\Grid;
|
|
|
|
use App\Enums\DrawActivityStatus;
|
|
use App\Models\DrawActivity;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Illuminate\Http\Request;
|
|
|
|
class DrawActivityClose extends RowAction
|
|
{
|
|
public function title()
|
|
{
|
|
return '<i class="feather icon-x-circle grid-action-icon"></i> 关闭';
|
|
}
|
|
|
|
/**
|
|
* @param Model|Authenticatable|HasPermissions|null $user
|
|
*
|
|
* @return bool
|
|
*/
|
|
protected function authorize($user): bool
|
|
{
|
|
return $user->can('dcat.admin.draw_activities.close');
|
|
}
|
|
|
|
public function confirm()
|
|
{
|
|
return '您确定要关闭选中的抽奖活动吗?';
|
|
}
|
|
|
|
public function handle(Request $request)
|
|
{
|
|
$drawActivity = DrawActivity::findOrFail($this->getKey());
|
|
|
|
$drawActivity->update([
|
|
'status' => DrawActivityStatus::Closed,
|
|
]);
|
|
|
|
return $this->response()->success('操作成功')->refresh();
|
|
}
|
|
}
|