DEV Community

Discussion on: 4 Steps to Automate Repeated Tasks Using Laravel

Collapse
 
skiabox profile image
Stavros Kefaleas

Nice work!
Although when I try the

php artisan app:load_api_data

step I get the following error :

 ErrorException 

  Trying to get property 'date' of non-object

  at app/Helpers/Misc.php:21
    17|         $updatedAt = $jobStart->toDateTimeString(); // 2015-12-19 10:10:16
    18| 
    19|         $earliestDate = JobDate::where('type', 'earliest date')->first();
    20|         $latestDate = JobDate::where('type', 'latest date')->first();
  > 21|         $fEarliestDate = substr($earliestDate->date, 0, 4)
    22|             . '-' . substr($earliestDate->date, 5, 2) . '-' . substr($earliestDate->date, 8, 2);
    23|         $fLatestDate = substr($latestDate->date, 0, 4)
    24|             . '-' . substr($latestDate->date, 5, 2) . '-' . substr($latestDate->date, 8, 2);
    25|         $cEarliestDate = Carbon::createFromFormat('Y-m-d', $fEarliestDate);

  1   app/Helpers/Misc.php:21
      Illuminate\Foundation\Bootstrap\HandleExceptions::handleError()

  2   app/Jobs/LoadApiDataJob.php:38
      App\Helpers\Misc::jobStart()