我正在将请求传递给工作类,以发送电子邮件以获取联系表。问题是我无法直接访问该属性。
我将构造函数中的 $request 设置为$this->request = $request;
在handle()
方法中,我这样做:
\Log::info('job-contact-request', ['request' => $this->request]);
日志吐出:
[2018-06-30 14:07:34] local.INFO: request {"request":"[object] (App\Events\ContactRequestValidated: {\"request\":{\"client_name\":\"Daniel \",\"client_email\":\"email@email.com\",\"client_phone\":\"1234567891\",\"client_text\":\"blargle carble darble zarble\"},\"socket \“:无效的})”}
这表明 client_email 已设置。但是当我尝试访问时$this->request->client_email
,我得到:
[2018-06-30 14:15:30] local.ERROR: 未定义属性:App\Events\ContactRequestValidated::$client_email {"exception":"[object] (ErrorException(code: 0): Undefined property: App\ Events\ContactRequestValidated::$client_email at /var/www/site/laravel/app/Jobs/SendContactRequestEmail.php:36) [stacktrace]