新增商品已下架异常
parent
eefe2152c0
commit
05a86b9ff1
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Endpoint\Api\Http\Controllers;
|
||||
|
||||
use App\Endpoint\Api\Http\Resources\ShoppingCartItemResource;
|
||||
use App\Exceptions\BizException;
|
||||
use App\Exceptions\ProductOfflineException;
|
||||
use App\Models\ProductSku;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ class ShoppingCartItemController extends Controller
|
|||
$sku = ProductSku::whereRelation('category', 'is_show', true)->online()->find($input['sku_id']);
|
||||
|
||||
if ($sku === null) {
|
||||
throw new BizException(__('Product has been removed'));
|
||||
throw new ProductOfflineException();
|
||||
}
|
||||
|
||||
$item = $request->user()->shoppingCartItems()->firstOrCreate([
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class ProductOfflineException extends BizException
|
||||
{
|
||||
public function __construct(string $message = '商品已下架')
|
||||
{
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
"Invalid verification code type": "无效的验证码类型",
|
||||
"Invalid old password": "原密码错误",
|
||||
"Inviter does not exist": "邀请人不存在",
|
||||
"Product has been removed": "商品已下架",
|
||||
"Registration failed, please try again": "注册失败,请重试",
|
||||
"Sending too frequently, please try again later": "发送过于频繁,请稍后再试",
|
||||
"The phone number is already registered": "手机号码已被注册",
|
||||
|
|
|
|||
Loading…
Reference in New Issue