我尝试使用job
模型将数据传递到Lumen
中的eloquent
个队列。
我收到错误trying to get property of non-object
这是我的Job类
<?php
namespace App\Jobs;
use App;
class CustomerSignupEmailJob extends Job
{
protected $getUser;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($getUser)
{
$this->user = $getUser;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
$mailer = app()->make('mailer');
$mailer->send('emails.backend-customer-signup', ['user' => $this->getUser] , function ($message) {
$message->from('xxx@xxx.com', 'Laravel');
$message->to('xxx@gmail.com')->cc('xxx@yahoo.co.uk');
});
}
}
Mail
期望数组作为第二个数据
这是我的控制器代码;
$getUser = Customer::where('email', $email)->first();
$job1 = (new CustomerSignupEmailJob($getUser));
$this->dispatch($job1);
您可以看到我将Customer
取为$getUser
并传递给它。
这是我的电子邮件视图;
Customer First Name: {{$user->first_name}}
Customer Last Name: {{$user->last_name}}
Customer Email: {{$user->email}}
Customer Phone Number: {{$user->mobile_phone}}
Customer Address Line 1: {{$user->address_line1}}
Customer Address Line 2: {{$user->address_line2}}
Customer Address Line 3: {{$user->address_line3}}
Customer Location: {{$user->location_id}}
Customer City: {{$user->city_id}}
我对如何在job class
中传递和访问数据感到困惑
任何建议表示赞赏。
答案 0 :(得分:1)
在构造函数中更改
<script>
$.getJSON('https://www.googleapis.com/youtube/v3/videospart=statistics&id=Qq7mpb-hCBY&key=Your-Api-Key', function(data) {
console.log("viewCount: ", data.items[ 0 ].statistics.viewCount);
});
</script>
要
$this->user = $getUser
在处理程序中,使用队列。
$this->getUser = $getUser