mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 00:02:15 +00:00
backend update
This commit is contained in:
@@ -26,10 +26,22 @@ class SubscriptionController extends Controller
|
||||
$plan = app('rinvex.subscriptions.plan')
|
||||
->find($request->input('plan.data.id'));
|
||||
|
||||
// Create subscription
|
||||
$user->newSubscription('main', $plan);
|
||||
// Check if user have subscription
|
||||
if ($user->activeSubscriptions()->count() !== 0) {
|
||||
|
||||
// Update user storage limig
|
||||
// Get old subscription
|
||||
$subscription = $user->subscription('main');
|
||||
|
||||
// Change subscription plan
|
||||
$subscription->changePlan($plan);
|
||||
|
||||
} else {
|
||||
|
||||
// Create subscription
|
||||
$user->newSubscription('main', $plan);
|
||||
}
|
||||
|
||||
// Update user storage limit
|
||||
$user->settings()->update([
|
||||
'storage_capacity' => $plan->features->first()->value
|
||||
]);
|
||||
@@ -41,4 +53,20 @@ class SubscriptionController extends Controller
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel Subscription
|
||||
*
|
||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
|
||||
*/
|
||||
public function cancel() {
|
||||
|
||||
// Get user
|
||||
$user = Auth::user();
|
||||
|
||||
// Cancel subscription
|
||||
$user->subscription('main')->cancel();
|
||||
|
||||
return response('Done!', 204);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user