/** * @param string $key * * @return ExportJob|null */ public function findByKey(string $key) : ExportJob { $result = $this->user->exportJobs()->where('key', $key)->first(['export_jobs.*']); if (is_null($result)) { return new ExportJob(); } return $result; }