Skip to content

Commit 512bd79

Browse files
authored
Merge pull request #87 from laravel/html-string-cast
[2.x] Add HtmlString caster
2 parents d786e34 + 9ba4900 commit 512bd79

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Console/TinkerCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ protected function getCasters()
104104
{
105105
$casters = [
106106
'Illuminate\Support\Collection' => 'Laravel\Tinker\TinkerCaster::castCollection',
107+
'Illuminate\Support\HtmlString' => 'Laravel\Tinker\TinkerCaster::castHtmlString',
107108
];
108109

109110
if (class_exists('Illuminate\Database\Eloquent\Model')) {

src/TinkerCaster.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ public static function castCollection($collection)
6868
];
6969
}
7070

71+
/**
72+
* Get an array representing the properties of an html string.
73+
*
74+
* @param \Illuminate\Support\HtmlString $htmlString
75+
* @return array
76+
*/
77+
public static function castHtmlString($htmlString)
78+
{
79+
return [
80+
Caster::PREFIX_VIRTUAL.'html' => $htmlString->toHtml(),
81+
];
82+
}
83+
7184
/**
7285
* Get an array representing the properties of a model.
7386
*

0 commit comments

Comments
 (0)