Upgrade framework

This commit is contained in:
2023-11-14 16:54:35 +01:00
parent 1648a5cd42
commit 4fcf6fffcc
10548 changed files with 693138 additions and 466698 deletions

View File

@@ -68,6 +68,32 @@ class TinkerCaster
];
}
/**
* Get an array representing the properties of an html string.
*
* @param \Illuminate\Support\HtmlString $htmlString
* @return array
*/
public static function castHtmlString($htmlString)
{
return [
Caster::PREFIX_VIRTUAL.'html' => $htmlString->toHtml(),
];
}
/**
* Get an array representing the properties of a fluent string.
*
* @param \Illuminate\Support\Stringable $stringable
* @return array
*/
public static function castStringable($stringable)
{
return [
Caster::PREFIX_VIRTUAL.'value' => (string) $stringable,
];
}
/**
* Get an array representing the properties of a model.
*
@@ -84,10 +110,30 @@ class TinkerCaster
$model->getVisible() ?: array_diff(array_keys($attributes), $model->getHidden())
);
$hidden = array_flip($model->getHidden());
$appends = (function () {
return array_combine($this->appends, $this->appends);
})->bindTo($model, $model)();
foreach ($appends as $appended) {
$attributes[$appended] = $model->{$appended};
}
$results = [];
foreach (array_intersect_key($attributes, $visible) as $key => $value) {
$results[(isset($visible[$key]) ? Caster::PREFIX_VIRTUAL : Caster::PREFIX_PROTECTED).$key] = $value;
foreach ($attributes as $key => $value) {
$prefix = '';
if (isset($visible[$key])) {
$prefix = Caster::PREFIX_VIRTUAL;
}
if (isset($hidden[$key])) {
$prefix = Caster::PREFIX_PROTECTED;
}
$results[$prefix.$key] = $value;
}
return $results;