PATH:
home
/
lab2454c
/
costbloc.com
/
app
/
Models
<?php namespace App\Models; use App\Traits\ModelTraits\hasFiles; use DateTime; use Illuminate\Database\Eloquent\Model; class MetaData extends Model { use hasFiles; /** * @var array */ protected $fillable = ['key', 'value']; /** * @var array */ protected $dataTypes = ['boolean', 'integer', 'double', 'float', 'string', 'NULL']; /** * Whether or not to delete the Data on save. * * @var bool */ protected $markForDeletion = false; /** * Whether or not to delete the Data on save. * * @param bool $bool */ public function markForDeletion($bool = true) { $this->markForDeletion = $bool; } /** * Check if the model needs to be deleted. * * @return bool */ public function isMarkedForDeletion() { return (bool) $this->markForDeletion; } /** * Set the value and type. * * @param $value */ 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(); } list($class, $id) = explode('#', $value); return with(new $class())->findOrFail($id); } } if (in_array($type, $this->dataTypes)) { settype($value, $type); } return $value; } }
[-] TransactionReference.php
[edit]
[-] Attribute.php
[edit]
[-] ProductStats.php
[edit]
[-] Language.php
[edit]
[-] CategoryAttribute.php
[edit]
[-] File.php
[edit]
[-] Review.php
[edit]
[+]
..
[-] Favorite.php
[edit]
[-] OrderStatus.php
[edit]
[-] OrderNoteHistory.php
[edit]
[-] Country.php
[edit]
[-] Permission.php
[edit]
[-] Address.php
[edit]
[-] Seo.php
[edit]
[-] EmailTemplate.php
[edit]
[-] AttributeGroup.php
[edit]
[-] Model.php
[edit]
[-] WithdrawalMethod.php
[edit]
[-] Preference.php
[edit]
[-] ProductMeta.php
[edit]
[-] Category.php
[edit]
[-] RoleUser.php
[edit]
[-] Order.php
[edit]
[-] UserSearch.php
[edit]
[-] Location.php
[edit]
[-] Wishlist.php
[edit]
[-] ProductTag.php
[edit]
[-] Customer.php
[edit]
[-] FlashSale.php
[edit]
[-] OrderStatusRole.php
[edit]
[-] ProductCrossSale.php
[edit]
[-] OrderStatusHistory.php
[edit]
[-] OrderDetail.php
[edit]
[-] Brand.php
[edit]
[-] ProductUpsale.php
[edit]
[-] Wallet.php
[edit]
[-] PasswordReset.php
[edit]
[-] AttributeValue.php
[edit]
[-] OrderMeta.php
[edit]
[-] Transaction.php
[edit]
[-] Product.php
[edit]
[-] UserWithdrawalSetting.php
[edit]
[-] EmailConfiguration.php
[edit]
[-] Currency.php
[edit]
[-] PermissionRole.php
[edit]
[-] ProductRelate.php
[edit]
[-] Search.php
[edit]
[-] User.php
[edit]
[-] VendorUser.php
[edit]
[-] themes.php
[edit]
[-] Role.php
[edit]
[-] ProductCategory.php
[edit]
[-] Tag.php
[edit]
[-] MetaData.php
[edit]
[-] Vendor.php
[edit]