68 lines
1.5 KiB
PHP
68 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Actions\Grid;
|
|
|
|
use App\Models\OrderPackage;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Throwable;
|
|
|
|
class OrderPackageFailed extends RowAction
|
|
{
|
|
/**
|
|
* @return string
|
|
*/
|
|
protected $title = '<i class="feather icon-eye-off grid-action-icon"></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.users.enable');
|
|
}
|
|
|
|
/**
|
|
* Handle the action request.
|
|
*
|
|
* @param Request $request
|
|
*
|
|
* @return Response
|
|
*/
|
|
public function handle(Request $request)
|
|
{
|
|
$package = OrderPackage::findOrFail($this->getKey());
|
|
try {
|
|
DB::beginTransaction();
|
|
$user->enable();
|
|
DB::commit();
|
|
} catch (Throwable $th) {
|
|
DB::rollBack();
|
|
report($th);
|
|
return $this->response()->error('操作失败,'.$th->getMessage())->refresh();
|
|
}
|
|
|
|
return $this->response()->success('操作成功')->refresh();
|
|
}
|
|
|
|
/**
|
|
* @return string|array|void
|
|
*/
|
|
public function confirm()
|
|
{
|
|
return ['确认作废当前货运单?', '该操作不可逆,确认后将作废该货运单,且订单相应恢复。'];
|
|
}
|
|
}
|