title: Add property and value in a object array
body: <p>im quite new in php OOP, and im using laravel has my framework of choice. Im creating a object user and create the record, the only thing i have to do is to check if one of my input fields(not required) was set, if it was set than i have to add in in the user object, but how can i add this property (mobilephone) and value in a exiting object, am i doing it right?.</p>
  
  <p>code:</p>
  
  <pre><code>$user = User::create([
      'email'              =&gt; $userDat['email'],
      'name'               =&gt; $userDat['name'],
      'surname'            =&gt; $userDat['surname'],
  ]);
  
  if (isset($userDat['mobilephone'])) {
      $user-&gt;mobilephone = $userDat['mobilephone'];
  }
  </code></pre>