lasthourcloud/bootstrap/helpers/subscriptions.php

44 lines
1.3 KiB
PHP
Raw Normal View History

2023-07-13 20:03:27 +00:00
<?php
use Illuminate\Support\Carbon;
function getSubscriptionLink()
{
$user_id = auth()->user()->id;
$team_id = auth()->user()->currentTeam()->id ?? null;
$email = auth()->user()->email ?? null;
$name = auth()->user()->name ?? null;
$url = "https://store.coollabs.io/checkout/buy/d0b28c6a-9b57-40bf-8b84-89fbafde6526?";
if ($user_id) {
$url .= "&checkout[custom][user_id]={$user_id}";
}
if (isset($team_id)) {
$url .= "&checkout[custom][team_id]={$team_id}";
}
if ($email) {
$url .= "&checkout[email]={$email}";
}
if ($name) {
$url .= "&checkout[name]={$name}";
}
return $url;
}
2023-07-14 09:27:08 +00:00
function getPaymentLink()
{
2023-07-13 20:03:27 +00:00
return auth()->user()->currentTeam()->subscription->lemon_update_payment_menthod_url;
}
2023-07-14 09:27:08 +00:00
function getRenewDate()
{
2023-07-13 20:03:27 +00:00
return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_renews_at)->format('Y-M-d H:i:s');
}
2023-07-14 09:27:08 +00:00
function getEndDate()
{
return Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_ends_at)->format('Y-M-d H:i:s');
}
function isSubscribed()
{
return
auth()->user()?->currentTeam()?->subscription?->lemon_status === 'active' ||
(auth()->user()?->currentTeam()?->subscription?->lemon_ends_at && Carbon::parse(auth()->user()->currentTeam()->subscription->lemon_ends_at) > Carbon::now());
}