66 lines
1.5 KiB
PHP
66 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Actions\Grid;
|
|
|
|
use App\Models\QuotaV1SendJob;
|
|
use Dcat\Admin\Actions\Response;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Illuminate\Http\Request;
|
|
use Throwable;
|
|
|
|
class QuotaV1SendJobStart extends RowAction
|
|
{
|
|
/**
|
|
* @return string
|
|
*/
|
|
protected $title = '<i class="feather grid-action-icon icon-play-circle"></i>';
|
|
|
|
public function title()
|
|
{
|
|
if ($this->title) {
|
|
return $this->title.' 开始任务';
|
|
}
|
|
|
|
return '开始任务';
|
|
}
|
|
|
|
/**
|
|
* @param Model|Authenticatable|HasPermissions|null $user
|
|
*
|
|
* @return bool
|
|
*/
|
|
protected function authorize($user): bool
|
|
{
|
|
return $user->can('dcat.admin.quota_v2_send_jobs.start');
|
|
}
|
|
|
|
/**
|
|
* Handle the action request.
|
|
*
|
|
* @param Request $request
|
|
*
|
|
* @return Response
|
|
*/
|
|
public function handle(Request $request)
|
|
{
|
|
try {
|
|
QuotaV1SendJob::findOrFail($this->getKey())->update([
|
|
'status' => QuotaV1SendJob::STATUS_DOING,
|
|
]);
|
|
} catch (Throwable $th) {
|
|
report($th);
|
|
return $this->response()->error('开始失败,'.$th->getMessage())->refresh();
|
|
}
|
|
|
|
return $this->response()->success('操作成功')->refresh();
|
|
}
|
|
|
|
/**
|
|
* @return string|array|void
|
|
*/
|
|
public function confirm()
|
|
{
|
|
return ['确认开始执行当前任务?', '确认后将针对任务金额开始分红,无法逆转。'];
|
|
}
|
|
}
|