1
0
mirror of https://github.com/v2board/v2board.git synced 2025-04-20 08:32:36 +08:00
This commit is contained in:
root 2020-01-02 00:43:25 +08:00
parent afc9d64aab
commit 5d7b5eb8f6
2 changed files with 18 additions and 20 deletions

@ -26,10 +26,16 @@ class CouponController extends Controller
'limit_use' 'limit_use'
]); ]);
if (!$request->input('id')) {
$params['code'] = Helper::randomChar(8); $params['code'] = Helper::randomChar(8);
if (!Coupon::create($params)) { if (!Coupon::create($params)) {
abort(500, '创建失败'); abort(500, '创建失败');
} }
} else {
if (!Coupon::find($request->input('id'))->update($params)) {
abort(500, '保存失败');
}
}
return response([ return response([
'data' => true 'data' => true

@ -22,23 +22,15 @@ class NoticeController extends Controller
'content', 'content',
'img_url' 'img_url'
]); ]);
if (!$request->input('id')) {
if (!Notice::create($data)) { if (!Notice::create($data)) {
abort(500, '保存失败'); abort(500, '保存失败');
} }
return response([ } else {
'data' => true if (!Notice::find($request->input('id'))->update($data)) {
]);
}
public function update (NoticeSave $request) {
$data = $request->only([
'title',
'content',
'img_url'
]);
if (!Notice::where('id', $request->input('id'))->update($data)) {
abort(500, '保存失败'); abort(500, '保存失败');
} }
}
return response([ return response([
'data' => true 'data' => true
]); ]);