title: Undefined property: stdClass::$account_id error in my code
body: <p>I have encountered the following error </p>
  
  <blockquote>
    <p>Undefined property: stdClass::$account_id (View:
    C:\xampp\htdocs\laravel\awsconfig\app\views\search.blade.php)</p>
  </blockquote>
  
  <p>here is the code which is causing this error :</p>
  
  <pre><code>$resource_types = array();
  $resource_types['AWS::EC2::Instance'] = 'EC2Instance';
  $resource_types['AWS::EC2::NetworkInterface'] = 'EC2NetworkInterface';
  $resource_types['AWS::EC2::VPC'] = 'VPC';
  $resource_types['AWS::EC2::Volume'] = 'Volume';
  $resource_types['AWS::EC2::SecurityGroup'] = 'EC2SecurityGroup';
  $resource_types['AWS::EC2::Subnet'] = 'Subnet';
  $resource_types['AWS::EC2::RouteTable'] = 'RouteTable';
  $resource_types['AWS::EC2::EIP'] = 'EIP';
  $resource_types['AWS::EC2::NetworkAcl'] = 'NetworkAcl';
  $resource_types['AWS::EC2::InternetGateway'] = 'InternetGateway';
  
  
   $accounts = DB::table('aws_account')-&gt;get();
   $account_list = array();
  
  
  
  
  foreach(glob('../app/views/*.json') as $filename)
  {
      //echo $filename;
      $data = file_get_contents($filename);
  
      if($data!=null)
  
      {
  
  
              $decoded=json_decode($data,true);  
  
  
              if(isset($decoded["Message"])) 
              { 
              //echo "found message&lt;br&gt;";
                  $message= json_decode($decoded["Message"]);
  if(isset($message-&gt;configurationItem))
  {
  //  echo"found cfi&lt;br&gt;";    
              $insert_array = array();
                  $cfi = $message-&gt;configurationItem;
                  switch ($cfi-&gt;configurationItemStatus)
                  {
  
                      case "ResourceDiscovered":
                  //echo"found Resource Discovered&lt;br&gt;";  
                          if (array_key_exists($cfi-&gt;resourceType,$resource_types))
  
                          {
                              //var_dump($cfi-&gt;resourceType);
                              $resource = new $resource_types[$cfi-&gt;resourceType];
  
                              foreach ($cfi-&gt;configuration as $key =&gt; $value)
                              {
                                  if (in_array($key,$resource-&gt;fields))
                                  {
                                      $insert_array[from_camel_case($key)] = $value;
                                  }
                              }
  
  
  
  
                              $resource-&gt;populate($insert_array);
                              if (!$resource-&gt;checkExists())
                              {
                                  $resource-&gt;save();
  
                                      if(isset($cfi-&gt;configuration-&gt;tags))
                                      {
                                         foreach ($cfi-&gt;configuration-&gt;tags as $t )
  
                                          {
  
                                          $tag= new Tag;
                                      $tag-&gt;resource_type = "instance";
  
                                      $tag-&gt;resource_id = $resource-&gt;id;
                                      $tag-&gt;key = $t-&gt;key;
                                      $tag-&gt;value = $t-&gt;value;
  
                                      $tag-&gt;save();
  
  
                                          if(isset($cfi-&gt;awsAccountId))
                                      {
                                       foreach ($accounts as $a)
  
                                       {
                                         $account_list[] = $a-&gt;account_id;
                                       }
  
  
                                      if (!in_array($account_id,$account_list))
                                      {
  
  
  
                                      $account_id = new Account;
                                      $account_id-&gt;aws_account_id = $cfi-&gt;awsAccountId;
  
                                      $account_list[] = $account_id;
                                       $account_id-&gt;save();
  
                                          }        
  
  
  
  
  
  
                                  }
                                  }
  }
  
  
  
  
                              }
  
                          }
  
                          else
                          {
                              echo "Creating ".$cfi["resourceType"]." not yet supported&lt;br&gt;";
                          }
  
  
  
  
  
                      break;
  </code></pre>
  
  <p>I know it will be something silly I appreciate all help as always thanks </p>