芝麻web文件管理V1.00
编辑当前文件:/home/digitalh/panorama.panoramawholesale.com/app/Models/MetaData.php
markForDeletion = $bool; } /** * Check if the model needs to be deleted. * * @return bool */ public function isMarkedForDeletion() { return (bool) $this->markForDeletion; } /** * Set the value and type. */ public function setValueAttribute($value) { $type = gettype($value); if (is_array($value)) { $this->type = 'array'; $this->attributes['value'] = json_encode($value); } elseif ($value instanceof DateTime) { $this->type = 'datetime'; $this->attributes['value'] = $this->fromDateTime($value); } elseif ($value instanceof Model) { $this->type = 'model'; $this->attributes['value'] = get_class($value) . (! $value->exists ? '' : '#' . $value->getKey()); } elseif (is_object($value)) { $this->type = 'object'; $this->attributes['value'] = json_encode($value); } else { $this->type = in_array($type, $this->dataTypes) ? $type : 'string'; $this->attributes['value'] = $value; } } public function getValueAttribute($value) { $type = $this->type ?: 'null'; switch ($type) { case 'array': return json_decode($value, true); case 'object': return json_decode($value); case 'datetime': return $this->asDateTime($value); case 'model': if (strpos($value, '#') === false) { return new $value(); } [$class, $id] = explode('#', $value); return with(new $class())->findOrFail($id); } if (in_array($type, $this->dataTypes)) { settype($value, $type); } return $value; } }