-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathDeveloperAccount.php
More file actions
79 lines (65 loc) · 1.86 KB
/
DeveloperAccount.php
File metadata and controls
79 lines (65 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace App\Models;
use App\Enums\StripeConnectStatus;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class DeveloperAccount extends Model
{
use HasFactory;
public const CURRENT_PLUGIN_TERMS_VERSION = '1.0';
protected $guarded = [];
/**
* @return BelongsTo<User, DeveloperAccount>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* @return HasMany<Plugin>
*/
public function plugins(): HasMany
{
return $this->hasMany(Plugin::class);
}
/**
* @return HasMany<PluginPayout>
*/
public function payouts(): HasMany
{
return $this->hasMany(PluginPayout::class);
}
public function isActive(): bool
{
return $this->stripe_connect_status === StripeConnectStatus::Active;
}
public function canReceivePayouts(): bool
{
return $this->isActive() && $this->payouts_enabled;
}
public function hasCompletedOnboarding(): bool
{
return $this->onboarding_completed_at !== null;
}
public function hasAcceptedPluginTerms(): bool
{
return $this->accepted_plugin_terms_at !== null;
}
public function hasAcceptedCurrentTerms(): bool
{
return $this->hasAcceptedPluginTerms()
&& $this->plugin_terms_version === self::CURRENT_PLUGIN_TERMS_VERSION;
}
protected function casts(): array
{
return [
'stripe_connect_status' => StripeConnectStatus::class,
'payouts_enabled' => 'boolean',
'charges_enabled' => 'boolean',
'onboarding_completed_at' => 'datetime',
'accepted_plugin_terms_at' => 'datetime',
];
}
}