sessionKey = Cookie::get('sessionKey'); $this->performer = AppSession::where('session_key', $this->sessionKey)->first(); $this->emailFromName = config('app.emailFromName'); $this->appUrl = config('app.url'); $this->emailService = $emailService; $this->appInternalName = config('app.internalName'); $this->stringMappingConfig = config('constants.' . $this->appInternalName); } public function previewEmail($email = null) { $pro = @$this->performer->pro; if (!$pro) { abort(404); } $appInternalName = $this->appInternalName; $stringMappingConfig = $this->stringMappingConfig; if ($email) { $destinationPath = resource_path('views/emails/templates/' . $email . '.blade.php'); if (File::exists($destinationPath)) { $content = File::get($destinationPath); $appUrl = $this->appUrl; $emailFromName = $this->emailFromName; $toEmailAddress = $this->pro ? $this->pro->email_address : 'john@doe.com'; $toName = $this->pro ? $this->pro->displayName() : 'John Doe'; $message = 'Client information has been updated'; $appointment = Appointment::first(); return view('emails/templates/' . $email, compact( 'appUrl', 'toEmailAddress', 'toName', 'message', 'stringMappingConfig', 'appInternalName', 'emailFromName', 'appointment' )); } else { abort(404); } } $files = File::allFiles(resource_path('views/emails/templates/')); $fileNames = []; foreach ($files as $file) { $fileName = $file->getFilename(); $fileNameParts = explode('.', $fileName); $fileRef = @$fileNameParts[0]; if ($fileRef) array_push($fileNames, $fileRef); } return view('emails.preview-email', compact('fileNames')); } }