feat: 添加产品购买链接添加接口
This commit is contained in:
@@ -261,6 +261,34 @@ class ProductPurchaseLink
|
||||
->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加购买链接
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$post = request()->post([
|
||||
'link',
|
||||
'product_id',
|
||||
'platform_id'
|
||||
]);
|
||||
$data = [
|
||||
'link' => $post['link'],
|
||||
'language_id' => request()->lang_id,
|
||||
'product_id' => $post['product_id'],
|
||||
'platform_id' => $post['platform_id']
|
||||
];
|
||||
$validate = new ProductPurchaseLinkValidate;
|
||||
if (!$validate->scene('add')->check($data)) {
|
||||
return error($validate->getError());
|
||||
}
|
||||
|
||||
$link = ProductPurchaseLinkModel::create($data);
|
||||
if ($link->isEmpty()) {
|
||||
return error('操作失败');
|
||||
}
|
||||
return success('操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新购买链接
|
||||
*/
|
||||
@@ -279,7 +307,7 @@ class ProductPurchaseLink
|
||||
'platform_id' => $put['platform_id']
|
||||
];
|
||||
$validate = new ProductPurchaseLinkValidate;
|
||||
if (!$validate->scene('update')->check($data)) {
|
||||
if (!$validate->scene('edit')->check($data)) {
|
||||
return error($validate->getError());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user