mirror of
https://github.com/v2board/v2board.git
synced 2025-01-31 02:29:14 +08:00
update
This commit is contained in:
parent
53a92569f5
commit
deba5a101b
@ -63,29 +63,20 @@ class PlanController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show (Request $request) {
|
public function update (Request $request) {
|
||||||
$plan = Plan::find($request->input('id'));
|
$updateData = $request->only([
|
||||||
if (!$plan) {
|
'show',
|
||||||
abort(500, '该订阅不存在');
|
'renew'
|
||||||
}
|
|
||||||
$plan->show = $plan->show ? 0 : 1;
|
|
||||||
if (!$plan->save()) {
|
|
||||||
abort(500, '更改失败');
|
|
||||||
}
|
|
||||||
return response([
|
|
||||||
'data' => true
|
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
|
|
||||||
public function renew (Request $request) {
|
|
||||||
$plan = Plan::find($request->input('id'));
|
$plan = Plan::find($request->input('id'));
|
||||||
if (!$plan) {
|
if (!$plan) {
|
||||||
abort(500, '该订阅不存在');
|
abort(500, '该订阅不存在');
|
||||||
}
|
}
|
||||||
$plan->renew = $plan->renew ? 0 : 1;
|
if (!$plan->update($updateData)) {
|
||||||
if (!$plan->save()) {
|
abort(500, '保存失败');
|
||||||
abort(500, '更改失败');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response([
|
return response([
|
||||||
'data' => true
|
'data' => true
|
||||||
]);
|
]);
|
||||||
|
@ -26,7 +26,7 @@ class UserController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function update (UserUpdate $request) {
|
public function update (UserUpdate $request) {
|
||||||
$fetchData = $request->only([
|
$updateData = $request->only([
|
||||||
'email',
|
'email',
|
||||||
'password',
|
'password',
|
||||||
'transfer_enable',
|
'transfer_enable',
|
||||||
@ -38,16 +38,16 @@ class UserController extends Controller
|
|||||||
if (!$user) {
|
if (!$user) {
|
||||||
abort(500, '用户不存在');
|
abort(500, '用户不存在');
|
||||||
}
|
}
|
||||||
if (User::where('email', $fetchData['email'])->first() && $user->email !== $fetchData['email']) {
|
if (User::where('email', $update['email'])->first() && $user->email !== $updateData['email']) {
|
||||||
abort(500, '邮箱已被使用');
|
abort(500, '邮箱已被使用');
|
||||||
}
|
}
|
||||||
if ($fetchData['password']) {
|
if ($updateData['password']) {
|
||||||
$fetchData['password'] = password_hash($fetchData['password'], PASSWORD_DEFAULT);
|
$updateData['password'] = password_hash($updateData['password'], PASSWORD_DEFAULT);
|
||||||
} else {
|
} else {
|
||||||
unset($fetchData['password']);
|
unset($updateData['password']);
|
||||||
}
|
}
|
||||||
$fetchData['transfer_enable'] = $fetchData['transfer_enable'] * 1073741824;
|
$updateData['transfer_enable'] = $updateData['transfer_enable'] * 1073741824;
|
||||||
if (!$user->update($fetchData)) {
|
if (!$user->update($updateData)) {
|
||||||
abort(500, '保存失败');
|
abort(500, '保存失败');
|
||||||
}
|
}
|
||||||
return response([
|
return response([
|
||||||
|
@ -26,7 +26,7 @@ Route::prefix('v1')
|
|||||||
Route::get('plan', 'Admin\\PlanController@index');
|
Route::get('plan', 'Admin\\PlanController@index');
|
||||||
Route::post('plan/save', 'Admin\\PlanController@save');
|
Route::post('plan/save', 'Admin\\PlanController@save');
|
||||||
Route::post('plan/drop', 'Admin\\PlanController@drop');
|
Route::post('plan/drop', 'Admin\\PlanController@drop');
|
||||||
Route::post('plan/show', 'Admin\\PlanController@show');
|
Route::post('plan/update', 'Admin\\PlanController@update');
|
||||||
// Server
|
// Server
|
||||||
Route::get('server', 'Admin\\ServerController@index');
|
Route::get('server', 'Admin\\ServerController@index');
|
||||||
Route::post('server/save', 'Admin\\ServerController@save');
|
Route::post('server/save', 'Admin\\ServerController@save');
|
||||||
|
Loading…
Reference in New Issue
Block a user