X7ROOT File Manager
Current Path:
/home/gfecatvj/sites/realesbar/platform/core/base/src/Traits
home
/
gfecatvj
/
sites
/
realesbar
/
platform
/
core
/
base
/
src
/
Traits
/
📁
..
📄
EnumCastable.php
(824 B)
📄
HasDeleteManyItemsTrait.php
(1.21 KB)
📄
LoadAndPublishDataTrait.php
(5.11 KB)
Editing: EnumCastable.php
<?php namespace Botble\Base\Traits; use Botble\Base\Supports\Enum; trait EnumCastable { /** * @param string $key * @param mixed $value * @return mixed */ protected function castAttribute($key, $value) { $castedValue = parent::castAttribute($key, $value); if ($castedValue === $value && !is_object($value)) { $castType = $this->getCasts()[$key]; if (class_exists($castType) and is_subclass_of($castType, Enum::class)) { $castedValue = new $castType($value); } } return $castedValue; } /** * Determine if the given key is cast using a custom class. * * @param string $key * @return bool */ protected function isClassCastable($key) { return false; } }
Upload File
Create Folder