Skip to content

Commit

Permalink
Add additional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
timcortesi committed Nov 15, 2024
1 parent fc49f62 commit bad8942
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 43 deletions.
8 changes: 4 additions & 4 deletions app/Observers/ModuleAssignmentObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function created(ModuleAssignment $moduleAssignment)
];
try {
Mail::to($user)->send(new AssignmentNotification($moduleAssignment,$user,$user_messages));
} catch (Throwable $e) {
// keep going
} catch (\Exception $e) {
Log::error('Error sending assignment email: '.$e->getMessage());
}
}
}
Expand All @@ -62,8 +62,8 @@ public function saved(ModuleAssignment $moduleAssignment){
];
try {
Mail::to($user)->send(new CompletionNotification($moduleAssignment,$user,$user_messages));
} catch (Throwable $e) {
// keep going
} catch (\Exception $e) {
Log::error('Error sending completion email: '.$e->getMessage());
}
}
}
Expand Down
63 changes: 24 additions & 39 deletions app/Observers/WorkshopAttendanceObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,21 @@ public function created(WorkshopAttendance $attendance)

$offering = WorkshopOffering::where('id',$attendance->workshop_offering_id)->first();
$workshop = Workshop::where('id',$attendance->workshop_id)->first();
// $offering = WorkshopOffering::where('id',$attendance)->first();
// $workshop = $offering->workshop;

// Don't send email if the assignment template is blank
if ($workshop->config != '') {

$user = User::where('id',$attendance->user_id)->first();

// if($user->active && $user->send_email_check()){
if($user->active ){
if($user->active ){
$user_messages =[
'workshop_name'=>$workshop->name,
'offering_date' =>$offering->workshop_date,
'notification'=> $workshop->config->notification
];

try {

Mail::to($user)->send(new WorkshopNotification($attendance,$user,$user_messages));
} catch (\Exception $e) {
dd($e);
Log::error('Error sending workshop notification email: '.$e->getMessage());
}
}
}
Expand All @@ -60,34 +54,28 @@ public function created(WorkshopAttendance $attendance)
*/
public function deleted(WorkshopAttendance $attendance)
{

// if($attendance->deleted_at != NULL){
$offering = WorkshopOffering::where('id',$attendance->workshop_offering_id)->first();
$workshop = Workshop::where('id',$attendance->workshop_id)->first();
$offering = WorkshopOffering::where('id',$attendance->workshop_offering_id)->first();
$workshop = Workshop::where('id',$attendance->workshop_id)->first();

// Don't send email if the assignment template is blank
if ($workshop->config != '') {

// Don't send email if the assignment template is blank
if ($workshop->config != '') {

$user = User::where('id',$attendance->user_id)->first();
$user = User::where('id',$attendance->user_id)->first();

// if($user->active && $user->send_email_check()){
if($user->active ){
$user_messages =[
'workshop_name'=>$workshop->name,
'offering_date' =>$offering->workshop_date,
'notification'=> $workshop->config->unregister
];

try {

Mail::to($user)->send(new WorkshopNotification($attendance,$user,$user_messages));
} catch (\Exception $e) {
dd($e);
}
if($user->active ){
$user_messages =[
'workshop_name'=>$workshop->name,
'offering_date' =>$offering->workshop_date,
'notification'=> $workshop->config->unregister
];

try {
Mail::to($user)->send(new WorkshopNotification($attendance,$user,$user_messages));
} catch (\Exception $e) {
Log::error('Error sending workshop notification email: '.$e->getMessage());
}
}
// }

}
}

/**
Expand All @@ -98,29 +86,26 @@ public function deleted(WorkshopAttendance $attendance)
*/
public function updated(WorkshopAttendance $attendance){

//when user status changes to completed
if($attendance->status == 'completed'){
//when user status changes to completed
if($attendance->status == 'completed'){
$offering = WorkshopOffering::where('id',$attendance->workshop_offering_id)->first();
$workshop = Workshop::where('id',$attendance->workshop_id)->first();

// Don't send email if the assignment template is blank
if ($workshop->config != '') {

$user = User::where('id',$attendance->user_id)->first();

// if($user->active && $user->send_email_check()){
if($user->active ){
if($user->active ){
$user_messages =[
'workshop_name'=>$workshop->name,
'offering_date' =>$offering->workshop_date,
'notification'=> $workshop->config->completion
];

try {

Mail::to($user)->send(new WorkshopNotification($attendance,$user,$user_messages));
} catch (\Exception $e) {
dd($e);
Log::error('Error sending workshop notification email: '.$e->getMessage());
}
}
}
Expand Down

0 comments on commit bad8942

Please sign in to comment.