1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sagitarius29\LaravelSubscriptions\Entities; |
4
|
|
|
|
5
|
|
|
use Carbon\Carbon; |
6
|
|
|
use Illuminate\Database\Eloquent\Model; |
7
|
|
|
use Illuminate\Database\Eloquent\Builder; |
8
|
|
|
use Sagitarius29\LaravelSubscriptions\Contracts\PlanContract; |
9
|
|
|
use Sagitarius29\LaravelSubscriptions\Contracts\SubscriptionContact; |
10
|
|
|
|
11
|
|
|
class Subscription extends Model implements SubscriptionContact |
12
|
|
|
{ |
13
|
|
|
protected $table = 'subscriptions'; |
14
|
|
|
|
15
|
|
|
protected $fillable = [ |
16
|
|
|
'plan_id', 'start_at', 'end_at', |
17
|
|
|
]; |
18
|
|
|
|
19
|
|
|
public function scopeCurrent(Builder $q, Carbon $date) |
20
|
|
|
{ |
21
|
|
|
return $q->where('start_at', '<', $date) |
22
|
|
|
->where('end_at', '>', $date); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function isPerpetual(): bool |
26
|
|
|
{ |
27
|
|
|
return $this->end_at == null; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function getDaysLeft(): int |
31
|
|
|
{ |
32
|
|
|
// TODO: Implement getDaysLeft() method. |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function getElapsedDays(): int |
36
|
|
|
{ |
37
|
|
|
// TODO: Implement getElapsedDays() method. |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function getExpirationDate(): ?Carbon |
41
|
|
|
{ |
42
|
|
|
// TODO: Implement getExpirationDate() method. |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getStartDate(): ?Carbon |
46
|
|
|
{ |
47
|
|
|
// TODO: Implement getStartDate() method. |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function subscriber() |
51
|
|
|
{ |
52
|
|
|
// TODO: Implement subscriber() method. |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public static function make(PlanContract $plan, Carbon $start_at, Carbon $end_at = null): Model |
56
|
|
|
{ |
57
|
|
|
return new self([ |
58
|
|
|
'plan_id' => $plan->id, |
|
|
|
|
59
|
|
|
'start_at' => $start_at, |
60
|
|
|
'end_at' => $end_at, |
61
|
|
|
]); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: