1 | <?php |
||
12 | class ValueCollection extends EloquentCollection |
||
13 | { |
||
14 | /** |
||
15 | * The entity this value collection belongs to. |
||
16 | * |
||
17 | * @var \Illuminate\Database\Eloquent\Model |
||
18 | */ |
||
19 | protected $entity; |
||
20 | |||
21 | /** |
||
22 | * The attribute this value collection is storing. |
||
23 | * |
||
24 | * @var \Rinvex\Attributes\Models\Attribute |
||
25 | */ |
||
26 | protected $attribute; |
||
27 | |||
28 | /** |
||
29 | * Link the entity and attribute to this value collection. |
||
30 | * |
||
31 | * @param \Illuminate\Database\Eloquent\Model $entity |
||
32 | * @param $attribute |
||
33 | * |
||
34 | * @return $this |
||
35 | */ |
||
36 | public function link($entity, $attribute) |
||
43 | |||
44 | /** |
||
45 | * Add new values to the value collection. |
||
46 | * |
||
47 | * @param \Illuminate\Support\Collection|array $values |
||
48 | * |
||
49 | * @return $this |
||
50 | */ |
||
51 | public function add($values) |
||
66 | |||
67 | /** |
||
68 | * Replace current values with the given values. |
||
69 | * |
||
70 | * @param \Illuminate\Support\Collection|array $values |
||
71 | * |
||
72 | * @return $this |
||
73 | */ |
||
74 | public function replace($values) |
||
88 | |||
89 | /** |
||
90 | * Trash the current values by queuing into entity object, |
||
91 | * these trashed values will physically deleted on entity save. |
||
92 | * |
||
93 | * @return void |
||
94 | */ |
||
95 | protected function trashCurrentItems(): void |
||
103 | |||
104 | /** |
||
105 | * Build a value instance from the given input. |
||
106 | * |
||
107 | * @param mixed $value |
||
108 | * |
||
109 | * @return \Illuminate\Database\Eloquent\Model |
||
110 | */ |
||
111 | protected function buildValue($value): Model |
||
127 | |||
128 | /** |
||
129 | * Build value instances from the given array. |
||
130 | * |
||
131 | * @param \Illuminate\Support\Collection|array $values |
||
132 | * |
||
133 | * @return \Rinvex\Attributes\Models\Value[] |
||
134 | */ |
||
135 | protected function buildValues($values) |
||
150 | } |
||
151 |