mirror of
https://github.com/v2board/v2board.git
synced 2025-01-27 16:39:08 +08:00
update plan
This commit is contained in:
parent
8ff53673d7
commit
0a92308ad2
@ -9,6 +9,7 @@ use App\Http\Controllers\Controller;
|
|||||||
use App\Models\Plan;
|
use App\Models\Plan;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class PlanController extends Controller
|
class PlanController extends Controller
|
||||||
{
|
{
|
||||||
@ -27,9 +28,21 @@ class PlanController extends Controller
|
|||||||
if (!$plan) {
|
if (!$plan) {
|
||||||
abort(500, '该订阅不存在');
|
abort(500, '该订阅不存在');
|
||||||
}
|
}
|
||||||
if (!$plan->update($params)) {
|
DB::beginTransaction();
|
||||||
|
if ($params->group_id !== $plan->group_id) {
|
||||||
|
if (!User::where('plan_id', $plan->id)
|
||||||
|
->get()
|
||||||
|
->update(['group_id', $plan->group_id])
|
||||||
|
) {
|
||||||
|
DB::rollBack();
|
||||||
abort(500, '保存失败');
|
abort(500, '保存失败');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!$plan->update($params)) {
|
||||||
|
DB::rollBack();
|
||||||
|
abort(500, '保存失败');
|
||||||
|
}
|
||||||
|
DB::commit();
|
||||||
return response([
|
return response([
|
||||||
'data' => true
|
'data' => true
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user