title: How to avoid error when using Eloquent's toArray when getting null result
body: <p>l am getting start at a new laravel project with 5.7, but one problem, when l use <code>first()</code> to fetch data, and if data is not exist, it will return <code>null</code>, and then execute <code>toArray()</code> will throw a PHP error. So l use follow code to reslove it. </p>
  
  <pre><code>$user_model = \App\Model\User::where('id', $id);
  
  if ($select) {
      $user_model-&gt;select(explode(',', $select));
  }
  
  $user_data = $user_model-&gt;first();
  $user_data = $user_data ?? $user_data-&gt;toArray();
  </code></pre>
  
  <p>So is there any better way?</p>