lasthourcloud/app/Models/Subscription.php

34 lines
849 B
PHP
Raw Normal View History

2023-07-13 15:07:42 +02:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Subscription extends Model
{
protected $guarded = [];
2023-07-13 15:07:42 +02:00
public function team()
{
return $this->belongsTo(Team::class);
}
2023-08-14 15:22:29 +02:00
public function type()
{
2023-08-23 16:40:59 +02:00
$basic = explode(',', config('subscription.lemon_squeezy_basic_plan_ids'));
$pro = explode(',', config('subscription.lemon_squeezy_pro_plan_ids'));
$ultimate = explode(',', config('subscription.lemon_squeezy_ultimate_plan_ids'));
2023-08-14 15:22:29 +02:00
$subscription = $this->lemon_variant_id;
if (in_array($subscription, $basic)) {
return 'basic';
}
if (in_array($subscription, $pro)) {
return 'pro';
}
if (in_array($subscription, $ultimate)) {
return 'ultimate';
}
return 'unknown';
}
2023-07-13 15:07:42 +02:00
}