v2board/app/Http/Controllers/PlanController.php

30 lines
730 B
PHP
Raw Normal View History

2019-10-22 23:39:48 +08:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Plan;
use App\Models\User;
class PlanController extends Controller
{
public function info (Request $request) {
if (empty($request->input('plan_id'))) {
abort(500, '参数错误');
}
$plan = Plan::find($request->input('plan_id'));
if (!$plan) {
2019-10-27 21:00:35 +08:00
abort(500, '该订阅不存在');
2019-10-22 23:39:48 +08:00
}
$user = User::find($request->session()->get('id'));
if (!($plan->show || $user->plan_id == $plan->id)) {
abort(500, '该订阅已售罄');
}
return response([
'data' => $plan
]);
}
}