-
Notifications
You must be signed in to change notification settings - Fork 0
/
AttributeGroup.php
executable file
·67 lines (58 loc) · 1.38 KB
/
AttributeGroup.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
<?php
namespace Eav;
use Illuminate\Database\Eloquent\Model;
class AttributeGroup extends Model
{
/**
* @{inheriteDoc}
*/
protected $primaryKey = 'attribute_group_id';
/**
* @{inheriteDoc}
*/
public $timestamps = false;
/**
* The model's default values for attributes.
*
* @var array
*/
protected $attributes = [
'sequence' => 0,
];
/**
* @{inheriteDoc}
*/
protected $fillable = [
'attribute_set_id', 'attribute_group_name', 'sequence'
];
/**
* Proxy to get the attribute group name.
*
* @return string
*/
public function name()
{
return $this->getAttribute('attribute_group_name');
}
/**
* Set the name.
*
* @param string $value
* @return void
*/
public function setNameAttribute($value)
{
$this->attributes['attribute_group_name'] = $value;
}
/**
* Get a has-many-through relation attributes by sequence order.
*
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
*/
public function attributes()
{
return $this->hasManyThrough(Attribute::class, EntityAttribute::class, 'attribute_group_id', 'attribute_id')
->select(['attributes.*', 'entity_attributes.sequence'])
->orderBy('entity_attributes.sequence');
}
}