我有两个laravel 5应用程序使用一个数据库和一个jobs
表。下面的crontab条目负责运行queue:work
命令:
# App2 - path to app 2 - App with Account model and accounts table
* * * * * fokwabest cd /opt/lampp/htdocs/app2/ && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1
# App1 - path to app 1 - App with User Model and users table
* * * * * fokwabest cd /opt/lampp/htdocs/app1/ && /usr/local/bin/php artisan schedule:run >> /dev/null 2>&1
我的队列驱动程序是数据库。我的密码重置电子邮件如下所示:
Dear {{ $user->name }},<br/><br/> <!-- I get the wrong name -->
{{ trans('passwords.password_email_text_one') }}
$user
来自以下方法:
public function emailResetLink(CanResetPasswordContract $user, $token, Closure $callback = null)
{
// We will use the reminder view that was given to the broker to display the
// password reminder e-mail. We'll pass a "token" variable into the views
// so that it may be displayed for an user to click for password reset.
$view = $this->emailView;
return $this->mailer->queue($view, compact('token', 'user'), function ($m) use ($user, $token, $callback) {
$m->to($user->getEmailForPasswordReset());
if (! is_null($callback)) {
call_user_func($callback, $m, $user, $token);
}
});
}
这是我的问题,当app1中的用户尝试通过提交他的电子邮件来恢复密码时,会更改查询帐户表而不是用户表,这会在发送给用户的电子邮件中给出错误的名称。可能是什么问题?
答案 0 :(得分:0)
在config / queue.php中建立一些连接,设置一个不同的表名,f.e。
'accountQueue' => [
'driver' => 'database',
'table' => 'accounts',
'queue' => 'accountqueue',
'expire' => 60,
],
'usersQueue' => [
'driver' => 'database',
'table' => 'users',
'queue' => 'userqueue',
'expire' => 60,
]
然后在添加作业时指定单独的连接,
Queue::connection("accountQueue")->push($job);
然后,使用
$ php artisan queue:work accountQueue
运行特定的队列连接