File size: 1,013 Bytes
89a1081
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<?php

namespace App\Models;

use App\Enums\PaymentStatusEnum;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Builder;
use App\Traits\Filterable;

class Subscription extends Model
{
    use HasFactory, Notifiable, Filterable;

    
    const RUNNING   = 1;
    const EXPIRED   = 2;
    const REQUESTED = 3;
    const INACTIVE  = 4;
    const RENEWED   = 5;
    

    protected $fillable = [
    	'user_id',
    	'plan_id',
    	'expired_date',
    	'trx_number',
    	'amount',
    	'status'
    ];

    protected $dates = ['created_at', 'updated_at', 'expired_date'];

    public function plan()
    {
    	return $this->belongsTo(PricingPlan::class, 'plan_id');
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function currentPlan()
    {
    	return $this->hasMany(PricingPlan::class, 'id', 'plan_id')->first();
    }
}