-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPurchaseLimit.php
95 lines (85 loc) · 2.14 KB
/
PurchaseLimit.php
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace Armezit\Lunar\PurchaseLimit\Models;
use Armezit\Lunar\PurchaseLimit\Database\Factories\PurchaseLimitFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Lunar\Models\Customer;
use Lunar\Models\CustomerGroup;
use Lunar\Models\Product;
use Lunar\Models\ProductVariant;
/**
* @property int $id
* @property int $product_id
* @property int $product_variant_id
* @property int $customer_group_id
* @property int $customer_id
* @property int $period
* @property int $max_quantity
* @property int $max_total
*/
class PurchaseLimit extends Model
{
use HasFactory;
use SoftDeletes;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'product_id',
'product_variant_id',
'customer_group_id',
'customer_id',
'period',
'max_quantity',
'max_total',
'starts_at',
'ends_at',
];
/**
* Get the table associated with the model.
*
* @return string
*/
public function getTable()
{
return config('lunarphp-purchase-limit.database.purchase_limits_table', 'purchase_limits');
}
/**
* Return a new factory instance for the model.
*/
protected static function newFactory(): PurchaseLimitFactory
{
return PurchaseLimitFactory::new();
}
/**
* Get the product that owns the item.
*/
public function product()
{
return $this->belongsTo(Product::class, 'product_id');
}
/**
* Get the product variant that owns the item.
*/
public function productVariant()
{
return $this->belongsTo(ProductVariant::class, 'product_variant_id');
}
/**
* Get the customer that owns the item.
*/
public function customerGroup()
{
return $this->belongsTo(CustomerGroup::class, 'customer_group_id');
}
/**
* Get the customer that owns the item.
*/
public function customer()
{
return $this->belongsTo(Customer::class, 'customer_id');
}
}