Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Database\Eloquent\Casts;
4
 
5
use Illuminate\Contracts\Database\Eloquent\Castable;
6
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
7
use Illuminate\Support\Str;
8
 
9
class AsStringable implements Castable
10
{
11
    /**
12
     * Get the caster class to use when casting from / to this cast target.
13
     *
14
     * @param  array  $arguments
399 lars 15
     * @return CastsAttributes<\Illuminate\Support\Stringable, string|\Stringable>
148 lars 16
     */
17
    public static function castUsing(array $arguments)
18
    {
19
        return new class implements CastsAttributes
20
        {
21
            public function get($model, $key, $value, $attributes)
22
            {
23
                return isset($value) ? Str::of($value) : null;
24
            }
25
 
26
            public function set($model, $key, $value, $attributes)
27
            {
28
                return isset($value) ? (string) $value : null;
29
            }
30
        };
31
    }
32
}