-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProductData.php
More file actions
85 lines (69 loc) · 2.02 KB
/
ProductData.php
File metadata and controls
85 lines (69 loc) · 2.02 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
80
81
82
83
84
85
<?php
namespace Eclipse\Catalogue\Models;
use Eclipse\Catalogue\Factories\ProductDataFactory;
use Eclipse\Core\Models\Site;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ProductData extends Model
{
use HasFactory;
protected $table = 'pim_product_data';
public $timestamps = false;
protected $fillable = [
'product_id',
'category_id',
'product_status_id',
'tax_class_id',
'sorting_label',
'is_active',
'available_from_date',
'has_free_delivery',
];
/**
* Include the tenant foreign key in fillable when tenancy is on.
*/
public function getFillable(): array
{
$fillable = $this->fillable;
if (config('eclipse-catalogue.tenancy.foreign_key')) {
$fillable[] = config('eclipse-catalogue.tenancy.foreign_key');
}
return $fillable;
}
public function product(): BelongsTo
{
return $this->belongsTo(Product::class);
}
public function category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
/** @return BelongsTo<ProductStatus> */
public function status(): BelongsTo
{
return $this->belongsTo(ProductStatus::class, 'product_status_id');
}
/** @return BelongsTo<\Eclipse\Catalogue\Models\TaxClass, self> */
public function taxClass(): BelongsTo
{
return $this->belongsTo(\Eclipse\Catalogue\Models\TaxClass::class, 'tax_class_id');
}
/** @return BelongsTo<\Eclipse\Core\Models\Site, self> */
public function site(): BelongsTo
{
return $this->belongsTo(Site::class);
}
protected function casts(): array
{
return [
'is_active' => 'boolean',
'available_from_date' => 'datetime',
'has_free_delivery' => 'boolean',
];
}
protected static function newFactory()
{
return ProductDataFactory::new();
}
}