1 | <?php |
||
8 | class Voucher extends Model |
||
9 | { |
||
10 | /** |
||
11 | * The attributes that are mass assignable. |
||
12 | * |
||
13 | * @var array |
||
14 | */ |
||
15 | protected $fillable = [ |
||
16 | 'model_id', |
||
17 | 'model_type', |
||
18 | 'code', |
||
19 | 'data', |
||
20 | 'expires_at' |
||
21 | ]; |
||
22 | |||
23 | /** |
||
24 | * The attributes that should be mutated to dates. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $dates = [ |
||
29 | 'expires_at' |
||
30 | ]; |
||
31 | |||
32 | /** |
||
33 | * The attributes that should be cast to native types. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $casts = [ |
||
38 | 'data' => 'collection' |
||
39 | ]; |
||
40 | |||
41 | public function __construct(array $attributes = []) |
||
47 | |||
48 | /** |
||
49 | * Get the users who redeemed this voucher. |
||
50 | * |
||
51 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
52 | */ |
||
53 | public function users() |
||
57 | |||
58 | /** |
||
59 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
60 | */ |
||
61 | public function model() |
||
65 | |||
66 | /** |
||
67 | * Check if code is expired. |
||
68 | * |
||
69 | * @return bool |
||
70 | */ |
||
71 | public function isExpired() |
||
75 | |||
76 | /** |
||
77 | * Check if code is not expired. |
||
78 | * |
||
79 | * @return bool |
||
80 | */ |
||
81 | public function isNotExpired() |
||
85 | } |
||
86 |