通过数据的Laravel通知
我试图通过laravel中的通知传递关系对象。我有可以有很多医生的诊所,也有只能属于一家诊所的医生。他们通过医生表上的外来id字段作为机构id连接。当有人创建医生时,他们通常同时创建机构。然而,他们也有可能通过选择表格选择现有的做法 当有人创建一个新的实践时,我可以将$doctor和$practice完美地传递给通知。但是当他们选择一个现有的实践时,我似乎不能调用现有的$practice来通过。这是我的密码: 新医生通知书 医生控制器 改变 到 当您创建一个新的实践时,您将整个实践对象发送给您的通知,但当它已经存在时,您只发送id通过数据的Laravel通知,laravel,Laravel,我试图通过laravel中的通知传递关系对象。我有可以有很多医生的诊所,也有只能属于一家诊所的医生。他们通过医生表上的外来id字段作为机构id连接。当有人创建医生时,他们通常同时创建机构。然而,他们也有可能通过选择表格选择现有的做法 当有人创建一个新的实践时,我可以将$doctor和$practice完美地传递给通知。但是当他们选择一个现有的实践时,我似乎不能调用现有的$practice来通过。这是我的密码: 新医生通知书 医生控制器 改变 到 当您创建一个新的实践时,您将整个实践对象发送给您的
return (new MailMessage)
->subject('MedReps Doctor Registration')
->line('Hello,')
->line('A new doctor has been registered:')
->line(' ')
->line($this->practice->name)
->line($this->practice->address)
->line(
$this->practice->city
. ', '
. $this->practice->state
. ' '
. $this->practice->zip
)
->line('Phone: ' . $this->practice->phone)
->line('Fax: ' . $this->practice->fax)
->line('Contact: ' . $this->practice->contact)
->line('Email: ' . $this->practice->email)
->line(' ')
->line(
$this->doctor->first_name
. ' '
. $this->doctor->last_name
. ', '
. $this->doctor->type
)
->line('NPI: ' . $this->doctor->npi)
->line('License: ' . $this->doctor->license)
->line($dea_line);
// If the practice already exists
if ($request->create_doctor_practice_type == 'existing') {
$doctor = new Doctor();
$doctor->practice_id = $request->practice;
... data ...
$doctor->save();
// Get Practice information for notification
$practice = Practice::select('id')
->where('id', $request->practice)
->first();
// Send notification
Notification::route('mail', 'jeremy@medrepsrx.com')
->notify(new NewDoctor($doctor, $practice));
// Create a new practice
} else {
$practice = new Practice();
... data ...
$practice->save();
$doctor = new Doctor();
... data ...
$doctor->save();
// Send notification
Notification::route('mail', 'jeremy@medrepsrx.com')
->notify(new NewDoctor($doctor, $practice));
}
$practice = Practice::select('id') ->where('id', $request->practice) ->first();
$practice = Practice::find($request->practice);