title: Laravel: ID as ValueObject is null after save
body: <p>I'm using ValueObject casting as an ID of my model. Everything works fine when I get a record from database, however when it coming to saving, the ID is null. If I comment &quot;casts&quot; out, ID is correct.</p>
  <p><strong>Example:</strong></p>
  <pre><code>$game = new Game($data);
  $game-&gt;created_by = $userId; // Id ValueObject
  $game-&gt;save();
  dd($game);
  // attributes:
  // &quot;id&quot; =&gt; null,
  // &quot;created_by&quot; =&gt; Id{#value: 10},
  </code></pre>
  <p><strong>Id ValueObject:</strong></p>
  <pre><code>class Id
  {
   public function get($model, $key, $value, $attributes)
   {
      $this-&gt;value = $value;
  
      return $this;
   }
  
   public function set($model, $key, $value, $attributes)
   {
      $this-&gt;value = $value;
   }
  
   public function value(): int
   {
      return $this-&gt;value;
   }
  
   public function __toString()
   {
      return (string) $this-&gt;value;
   }
  }
  </code></pre>
  <p><strong>Model:</strong></p>
  <pre><code>class Game extends Model
  {
    protected $casts = [
      'id' =&gt; Id::class
    ];
  }
  </code></pre>
  <p>What can I do with it?<br>
  Thanks in advance</p>