title: `Undefined Property` error in laravel jobs
body: <p>I am running a job in laravel the code of my job looks like:</p>
  <p><strong>app/jobs/StoreFloorPlan.php</strong></p>
  <pre><code>&lt;?php
  
  namespace App\Jobs;
  
  use App\Events\FloorPlanUploaded;
  use App\Http\Services\AmenityService;
  use App\Mail\CSVFailedJob;
  use App\Mail\CSVImportJobCompleted;
  use App\Mail\CSVImportJobPartiallyCompleted;
  
  use App\Models\Notice;
  use App\Models\Property;
  use App\Models\UnitTypeDetail;
  use Mail;
  
  use App\Models\FloorPlan;
  use Carbon\Carbon;
  use Illuminate\Bus\Queueable;
  use Illuminate\Queue\SerializesModels;
  use Illuminate\Queue\InteractsWithQueue;
  use Illuminate\Contracts\Queue\ShouldQueue;
  use Illuminate\Foundation\Bus\Dispatchable;
  use League\Csv\Reader;
  use League\Csv\Statement;
  
  class StoreFloorPlan implements ShouldQueue
  {
      use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  
      protected $data,$error_arr,$error_row_numbers,$table;
      /**
       * Create a new job instance.
       *
       * @return void
       */
      public function __construct($data,$error_arr,$error_row_numbers) {
          $this-&gt;data = $data;
          $this-&gt;error_arr = $error_arr;
          $this-&gt;error_row_numbers = $error_row_numbers;
          $this-&gt;table = 'floor_plans';
      }
  
      /**
       * Execute the job.
       *
       * @throws \League\Csv\Exception
       *
       * @return void
       */
      public function handle()
      {
  //        $result = 1/0;
          $header_row = $this-&gt;data['header_row'];
          $offset = $this-&gt;data['offset'];
          $limit = $this-&gt;data['limit'];
  //        $limit = 5;
          $filename = $this-&gt;data['file_name'];
          $service = new AmenityService();
          $dbase = new FloorPlan();
  
          $map_data = $this-&gt;data['map_data'];
  
          $db_header_obj = new FloorPlan();
  //        $db_header = $db_header_obj-&gt;getTableColumns();
  
          $csv_file_path = storage_path('app/files/floor-plan/').$filename;
          if (!ini_get(&quot;auto_detect_line_endings&quot;)) {
              ini_set(&quot;auto_detect_line_endings&quot;, TRUE);
          }
          $csv = Reader::createFromPath($csv_file_path, 'r');
  
          $input_bom = $csv-&gt;getInputBOM();
          if ($input_bom === Reader::BOM_UTF16_LE || $input_bom === Reader::BOM_UTF16_BE) {
              $csv-&gt;addStreamFilter('convert.iconv.UTF-16/UTF-8');
          }
  
  //        $csv-&gt;addStreamFilter('convert.iconv.ISO-8859-15/UTF-8');
  
  //        $csv-&gt;setOutputBOM(Reader::BOM_UTF8);
  //        $csv-&gt;addStreamFilter('convert.iconv.ISO-8859-15/UTF-8');
  
          $csv-&gt;setHeaderOffset($header_row);
  //        $csv_header = $csv-&gt;getHeader();
  
  
  
          $rec_arr = array();
  //        $properties_arr = array();
  
          $stmt = (new Statement())
              -&gt;offset($offset)
              -&gt;limit($limit)
          ;
  
          $records = $stmt-&gt;process($csv);
  
  
          foreach ($records as $record)
          {
              $record = array_merge($record, $this-&gt;data['additional_value']);
              $rec_arr[] = array_values($record);
          }
  
          $records_arr = $service-&gt;trimArray($rec_arr);
  
          if(count($records_arr)&gt;0)
          {
              foreach($records_arr as $ck =&gt; $cv) {
  
                  $floorPlanArr = array();
                  foreach ($map_data as $mk =&gt; $mv) {
                      if (isset($mv)) {
                          $floorPlanArr[$mv] = $cv[$mk];
                      }
                  }
                  $floorPlanArr['created_at'] = Carbon::now();
                  $floorPlanArr['updated_at'] = Carbon::now();
                  if (!array_key_exists('pricing_offset', $floorPlanArr)){
                      $floorPlanArr['pricing_offset'] = '';
                  }
  //                $properties_arr[] = $floorPlanArr;
  
                  try{
                      $unitTypeDetail = UnitTypeDetail::firstOrCreate([
                          'unit_type' =&gt; $floorPlanArr['unit_type'],
                          'property_id' =&gt; $this-&gt;data['property_id']
                      ]);
  
                      $floorPlan = FloorPlan::firstOrCreate(
                          [
                              'pms_property' =&gt; empty($floorPlanArr['pms_property'])?NULL:$floorPlanArr['pms_property'],
                              'pms_unit_type' =&gt; empty($floorPlanArr['pms_unit_type'])?NULL:$floorPlanArr['pms_unit_type'],
                              'description' =&gt; isset($floorPlanArr['description'])?$floorPlanArr['description']:NULL,
                              'beds' =&gt; isset($floorPlanArr['beds'])?$floorPlanArr['beds']:NULL,
                              'baths' =&gt; isset($floorPlanArr['baths'])?(int)$floorPlanArr['baths']:NULL,
                              'sqft' =&gt; $floorPlanArr['sqft'],
                              'unit_count' =&gt; $floorPlanArr['unit_count'],
                              'pricing_offset' =&gt; (empty($floorPlanArr['pricing_offset']) &amp;&amp;  $floorPlanArr['pricing_offset'] != '0')?NULL:$floorPlanArr['pricing_offset'],
                              'unit_type_id' =&gt; $unitTypeDetail-&gt;id,
                              'property_id' =&gt; $this-&gt;data['property_id'],
                          ]
                      );
  //                    Property::where('id',$this-&gt;data['property_id'])-&gt;update(['floor_file' =&gt; 2]);
  
                  } catch (\Exception $e) {
  
                      if(isset($e-&gt;errorInfo)){
                          $error_arr = $e-&gt;errorInfo[2];
                          $this-&gt;error_arr[] = str_replace('at row 1', '', $error_arr);
                      }else{
                          $this-&gt;error_arr[] = $e-&gt;getMessage();
                      }
  
                      $this-&gt;error_row_numbers[] = $this-&gt;data['row_value'];
                  }
  
                  $this-&gt;data['row_value'] = $this-&gt;data['row_value'] + 1;
              }
  
  
  
              $this-&gt;data['offset'] = $offset + $limit;
  
              $propertyInsertJob = (new StoreFloorPlan($this-&gt;data,$this-&gt;error_arr,$this-&gt;error_row_numbers))-&gt;delay(Carbon::now()-&gt;addSeconds(3));
              dispatch($propertyInsertJob);
  
          }else{
              $arr_data = array();
  
              $err_count = count($this-&gt;error_arr);
              if($err_count &gt; 0) {
                  Property::where('id',$this-&gt;data['property_id'])-&gt;update(['floor_file' =&gt; 3]);
                  $error = '';
                  if($err_count&gt;0){
                      $error .= &quot;Error occurred in following rows:&lt;br/&gt;&quot;;
                      for($i=0; $i&lt;$err_count; $i++){
                          $error .= $this-&gt;error_row_numbers[$i].' ( '.$this-&gt;error_arr[$i].' ) ';
                          $error .=&quot;&lt;br&gt;&quot;;
                      }
                      $error .= &quot;&lt;hr&gt;&quot;;
                  }
                  $array_from_to = array (
                      '[[USER_NAME]]' =&gt; $this-&gt;data['user']-&gt;name,
                      '[[FILENAME]]' =&gt; $filename,
                      '[[ERROR]]' =&gt; $error,
                  );
                  $mailBody = $this-&gt;service-&gt;formatMailBody('csv-insert-job-partially-completed',$array_from_to);
                  $arr_data['mailBody'] = $mailBody;
                  $slug = Notice::generateRandomSlug();
                  Notice::updateOrCreate(
                      [
                          'property_id' =&gt; $this-&gt;data['property_id'],
                          'file_type' =&gt; '2',
                      ],
                      [
                          'title' =&gt; 'File uploaded with errors',
                          'slug' =&gt; $slug,
                          'body' =&gt; json_encode($mailBody),
                          'user_id' =&gt; $this-&gt;data['user']-&gt;id,
                          'seen' =&gt; 'n'
                      ]
                  );
                  event(new FloorPlanUploaded($this-&gt;data['property_id']));
                  if($this-&gt;data['user']-&gt;email_notification == 'on'){
                      Mail::to($this-&gt;data['user']-&gt;email)-&gt;send(new CSVImportJobPartiallyCompleted($arr_data));
                  }
              }else{
                  Property::where('id',$this-&gt;data['property_id'])-&gt;update(['floor_file' =&gt; 1]);
                  $error = '';
                  $array_from_to = array (
                      '[[USER_NAME]]' =&gt; $this-&gt;data['user']-&gt;name,
                      '[[FILENAME]]' =&gt; $filename,
                      '[[ERROR]]' =&gt; $error,
                  );
                  $mailBody = $this-&gt;service-&gt;formatMailBody('csv-insert-job-completed',$array_from_to);
                  $arr_data['mailBody'] = $mailBody;
                  event(new FloorPlanUploaded($this-&gt;data['property_id']));
                  if($this-&gt;data['user']-&gt;email_notification == 'on'){
                      Mail::to($this-&gt;data['user']-&gt;email)-&gt;send(new CSVImportJobCompleted($arr_data));
                  }
              }
  
          }
  
          if (!ini_get(&quot;auto_detect_line_endings&quot;)) {
              ini_set(&quot;auto_detect_line_endings&quot;, FALSE);
          }
      }
  
  }
  
  </code></pre>
  <p>And, I am receiving error as</p>
  <pre><code>ErrorException: Undefined property: App\Jobs\StoreFloorPlan::$service in D:\wamp64\www\amenity\app\Jobs\StoreFloorPlan.php:215
  Stack trace:
  #0 D:\wamp64\www\amenity\app\Jobs\StoreFloorPlan.php(215): Illuminate\Foundation\Bootstrap\HandleExceptions-&gt;handleError(8, 'Undefined prope...', 'D:\\wamp64\\www\\a...', 215, Array)
  #1 [internal function]: App\Jobs\StoreFloorPlan-&gt;handle()
  #2 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(32): call_user_func_array(Array, Array)
  #3 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
  #4 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
  #5 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
  #6 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(94): Illuminate\Container\Container-&gt;call(Array)
  #7 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(128): Illuminate\Bus\Dispatcher-&gt;Illuminate\Bus\{closure}(Object(App\Jobs\StoreFloorPlan))
  #8 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(104): Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}(Object(App\Jobs\StoreFloorPlan))
  #9 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(98): Illuminate\Pipeline\Pipeline-&gt;then(Object(Closure))
  #10 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher-&gt;dispatchNow(Object(App\Jobs\StoreFloorPlan), false)
  #11 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Jobs\Job.php(88): Illuminate\Queue\CallQueuedHandler-&gt;call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
  #12 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(337): Illuminate\Queue\Jobs\Job-&gt;fire()
  #13 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(283): Illuminate\Queue\Worker-&gt;process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), Object(Illuminate\Queue\WorkerOptions))
  #14 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Worker.php(118): Illuminate\Queue\Worker-&gt;runJob(Object(Illuminate\Queue\Jobs\DatabaseJob), 'database', Object(Illuminate\Queue\WorkerOptions))
  #15 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(102): Illuminate\Queue\Worker-&gt;daemon('database', 'default', Object(Illuminate\Queue\WorkerOptions))
  #16 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Queue\Console\WorkCommand.php(86): Illuminate\Queue\Console\WorkCommand-&gt;runWorker('database', 'default')
  #17 [internal function]: Illuminate\Queue\Console\WorkCommand-&gt;handle()
  #18 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(32): call_user_func_array(Array, Array)
  #19 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
  #20 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
  #21 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Container\Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
  #22 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Console\Command.php(183): Illuminate\Container\Container-&gt;call(Array)
  #23 D:\wamp64\www\amenity\vendor\symfony\console\Command\Command.php(255): Illuminate\Console\Command-&gt;execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
  #24 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Console\Command.php(170): Symfony\Component\Console\Command\Command-&gt;run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
  #25 D:\wamp64\www\amenity\vendor\symfony\console\Application.php(1000): Illuminate\Console\Command-&gt;run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #26 D:\wamp64\www\amenity\vendor\symfony\console\Application.php(271): Symfony\Component\Console\Application-&gt;doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #27 D:\wamp64\www\amenity\vendor\symfony\console\Application.php(147): Symfony\Component\Console\Application-&gt;doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #28 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Console\Application.php(90): Symfony\Component\Console\Application-&gt;run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #29 D:\wamp64\www\amenity\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(133): Illuminate\Console\Application-&gt;run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #30 D:\wamp64\www\amenity\artisan(37): Illuminate\Foundation\Console\Kernel-&gt;handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  #31 {main}
  </code></pre>
  <p>I could not understand what is <code>property</code>. It is showing error in line number 215 but there is no property variable in entire file, instead there is <code>property_id</code>.</p>
  <p>Any suggestion how could I fix it or from where I could start debugging?</p>
  <p>Let me know if you need any further details.</p>