restaurant_id; $reminder = EmailReminder::where('restaurant_id', $restaurant_id) ->where('id', $reminder_id) ->first(); if (!$reminder) return false; // Check reminder is active $enable = $reminder->email_active; if (!$enable) return false; // Check reminder is for shifts or events $for_shifts = $reminder->for_shifts == 1; $for_events = $reminder->for_events == 1; // Check service exists and is used by this reminder $service_id = $this->shift_event_id; $service = Shift::where('restaurant_id', $restaurant_id)->where('id', $service_id)->first(); if ($service) { if (!$for_shifts) return false; } else { $service = Event::where('restaurant_id', $restaurant_id)->where('id', $service_id)->first(); if ($service) { if (!$for_events) return false; } else { return false; // Service not exists } } // Subject & Content $subject_b64 = $reminder->email_reminder['subject_'.$lang]; $content_b64 = $reminder->email_reminder['content_'.$lang]; $subject = base64_decode($subject_b64); $content = base64_decode($content_b64); $subject = $this->parseEmailTags($subject); $content = $this->parseEmailTags($content); // Booking user email $to = $this->email; if ($this->mailManager == null) { $this->mailManager = new MailManager($this->restaurant_id); } $notification = $this->storeEmailSent($to, $subject, $content, 'pending', 'email_reminder', $reminder_id); // Pixel code $pixel_code = alexr_get_pixel_code($this->uuid, $notification ? $notification->id : 0); // Send email $result = $this->mailManager->send_email($to, $subject, $content, $pixel_code); // Store the reminder as email_reminder type with the id of the reminder //$this->storeEmailSent($to, $subject, $content, $result, 'email_reminder', $reminder_id); $this->updateEmailSent($notification->id, $result); return $result; } }