title: Trying to get property 'stock_name' of non-object error while inserting data
body: <p>i am getting data using crawl and trying to insert into database. i get abbreviations of company name and have a command to get the full form of the abbreviations. it works fine if the company name already exists in companies table, and when the command handle is run new company name is also inserted and i can get the name from the table but cannot insert the name as it shows error. here is the code:</p>
  
  <pre><code>$data['symbol']=$es[1];
   $name=DB::table('companies')
            -&gt;select('stock_name')
            -&gt;where('stock_symbol',$data['symbol']=$es[1])
            -&gt;first();
  
    if(!empty($name-&gt;stock_name)){
  
       $data['company_name']= $name-&gt;stock_name;
    }else{
       \Artisan::call("company:handle");
  
         $name=DB::table('companies')
                  -&gt;select('stock_name')
                  -&gt;where('stock_symbol',$data['symbol']=$es[1])
                  -&gt;first();    
  
          $data['company_name']= $name-&gt;stock_name;
    }
  </code></pre>