mirror of
https://github.com/v2board/v2board.git
synced 2025-04-13 21:22:35 +08:00
update
This commit is contained in:
parent
afc9d64aab
commit
5d7b5eb8f6
@ -26,10 +26,16 @@ class CouponController extends Controller
|
|||||||
'limit_use'
|
'limit_use'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$params['code'] = Helper::randomChar(8);
|
if (!$request->input('id')) {
|
||||||
if (!Coupon::create($params)) {
|
$params['code'] = Helper::randomChar(8);
|
||||||
abort(500, '创建失败');
|
if (!Coupon::create($params)) {
|
||||||
}
|
abort(500, '创建失败');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!Coupon::find($request->input('id'))->update($params)) {
|
||||||
|
abort(500, '保存失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return response([
|
return response([
|
||||||
'data' => true
|
'data' => true
|
||||||
|
@ -22,22 +22,14 @@ class NoticeController extends Controller
|
|||||||
'content',
|
'content',
|
||||||
'img_url'
|
'img_url'
|
||||||
]);
|
]);
|
||||||
if (!Notice::create($data)) {
|
if (!$request->input('id')) {
|
||||||
abort(500, '保存失败');
|
if (!Notice::create($data)) {
|
||||||
}
|
abort(500, '保存失败');
|
||||||
return response([
|
}
|
||||||
'data' => true
|
} else {
|
||||||
]);
|
if (!Notice::find($request->input('id'))->update($data)) {
|
||||||
}
|
abort(500, '保存失败');
|
||||||
|
}
|
||||||
public function update (NoticeSave $request) {
|
|
||||||
$data = $request->only([
|
|
||||||
'title',
|
|
||||||
'content',
|
|
||||||
'img_url'
|
|
||||||
]);
|
|
||||||
if (!Notice::where('id', $request->input('id'))->update($data)) {
|
|
||||||
abort(500, '保存失败');
|
|
||||||
}
|
}
|
||||||
return response([
|
return response([
|
||||||
'data' => true
|
'data' => true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user