Created
May 12, 2020 14:07
-
-
Save MrMadClown/9dfec90263482036f9922c56de35dd36 to your computer and use it in GitHub Desktop.
\Illuminate\Database\Eloquent\Concerns\HasAttributes::originalIsEquivalent object cast comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ticket extends Model { | |
protected $casts = [ | |
'content' => 'object', | |
]; | |
} | |
$ticket = new Ticket(); | |
$ticket->content = \json_decode('{"key":""}'); | |
$ticket->save(); | |
var_dump($ticket->refresh()->content); // object(stdClass)#1 (1) { ["key"]=> string(0) "" } | |
$ticket = new Ticket(); | |
$ticket->content = \json_decode('{"key":null}'); | |
$ticket->save(); // No attributes are considered Dirty | |
var_dump($ticket->refresh()->content); // object(stdClass)#1 (1) { ["key"]=> string(0) "" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment