| @@ 212-229 (lines=18) @@ | ||
| 209 | * @param string|array $value |
|
| 210 | * @return bool |
|
| 211 | */ |
|
| 212 | public function setMeta($name, $value) |
|
| 213 | { |
|
| 214 | if (is_array($value) || is_object($value)) { |
|
| 215 | $value = Json::encode($value); |
|
| 216 | } |
|
| 217 | ||
| 218 | if ($this->getMeta($name) !== null) { |
|
| 219 | return $this->upMeta($name, $value); |
|
| 220 | } |
|
| 221 | ||
| 222 | $model = new MediaMeta([ |
|
| 223 | 'media_id' => $this->id, |
|
| 224 | 'name' => $name, |
|
| 225 | 'value' => $value, |
|
| 226 | ]); |
|
| 227 | ||
| 228 | return $model->save(); |
|
| 229 | } |
|
| 230 | ||
| 231 | /** |
|
| 232 | * Update meta data for current media. |
|
| @@ 259-276 (lines=18) @@ | ||
| 256 | * @param string|array $value |
|
| 257 | * @return bool |
|
| 258 | */ |
|
| 259 | public function setMeta($name, $value) |
|
| 260 | { |
|
| 261 | if (is_array($value) || is_object($value)) { |
|
| 262 | $value = Json::encode($value); |
|
| 263 | } |
|
| 264 | ||
| 265 | if ($this->getMeta($name) !== null) { |
|
| 266 | return $this->upMeta($name, $value); |
|
| 267 | } |
|
| 268 | ||
| 269 | $model = new PostMeta([ |
|
| 270 | 'post_id' => $this->id, |
|
| 271 | 'name' => $name, |
|
| 272 | 'value' => $value, |
|
| 273 | ]); |
|
| 274 | ||
| 275 | return $model->save(); |
|
| 276 | } |
|
| 277 | ||
| 278 | /** |
|
| 279 | * Update meta data for current post. |
|