6
0
Fork 0
jiqu-library-server/app/Admin/Actions/Grid/DealerDeliveryShipping.php

68 lines
1.6 KiB
PHP

<?php
namespace App\Admin\Actions\Grid;
use App\Enums\DealerDeliveryBillStatus;
use App\Models\DealerDeliveryBill;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Throwable;
class DealerDeliveryShipping extends RowAction
{
public function title()
{
if ($this->title) {
return $this->title;
}
return '<i class="feather icon-package grid-action-icon"></i> 确认发货 &nbsp;&nbsp;';
}
/**
* @param Model|Authenticatable|HasPermissions|null $user
*
* @return bool
*/
protected function authorize($user): bool
{
return true;
return $user->can('dcat.admin.dealer_delivery_bills.shipping');
}
/**
* Handle the action request.
*
* @param Request $request
*
* @return Response
*/
public function handle(Request $request)
{
$order = DealerDeliveryBill::findOrFail($this->getKey());
try {
DB::beginTransaction();
$order->update([
'status' => DealerDeliveryBillStatus::Shippinged,
]);
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 ['确认当前云仓单已发货?', '确认后将无法逆操作'];
}
}