function addLead(Request $request) { if ($request->ajax()) { $input = $request->all(); $webinar_id = $input['webinar_id']; $first_name = $input['first_name']; $last_name = $input['last_name']; $email = $input['email']; $response = array(); $rules = ['webinar_id' => 'required', 'first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email']; $validator = Validator::make($input, $rules); if ($validator->passes()) { $webinar = Webinar::find($webinar_id); if ($webinar) { $subscriber = Subscriber::whereEmail($email)->first(); if (!$subscriber) { $insert = ["first_name" => $first_name, "last_name" => $last_name, "email" => $email, "status" => "Active"]; $subscriber = Subscriber::create($insert); } $webinar_signup_subscribers_lists = $webinar->signup_subscribers_lists()->get(); foreach ($webinar_signup_subscribers_lists as $webinar_list) { // Attach New Subscriber with Webinar $webinar_list->subscribers()->detach($subscriber->id); $webinar_list->subscribers()->attach($subscriber->id); } $response = array('success' => true); } else { $errors = array("Webinar Not Found"); $response = array('success' => false, 'errors' => $errors); } } else { $errors = $validator->getMessageBag()->toArray(); $response = array('success' => false, 'errors' => $errors); } echo json_encode($response); } }
public function single_data_generate($max_no_of_dataset_per_data, $webinar_id, $data_no) { $data_to_return = []; if ($max_no_of_dataset_per_data < 5) { $max_no_of_dataset_per_data = 5; } /////////////////////////////////////////////////////////////////////////////////// $webinar = Webinar::find($webinar_id); $start_time = $webinar['starts_on']; $time = DB::select(DB::raw('SELECT NOW() AS end_time')); $end_time = $time[0]->end_time; //time(); $start = strtotime($start_time); $end = strtotime($end_time); $interval = ($end - $start) / $max_no_of_dataset_per_data; //return date('Y-m-d H:i:s', $interval); for ($x = $start; $x <= $end; $x += $interval) { $data_to_return[] = $this->one_entry($x, $webinar_id, $data_no); } //////////////////////////////////////////////////////////////////////////////////// /*for ($x = 1; $x <= $max_no_of_dataset_per_data; $x++) { $data_to_return[] = $this->one_entry($x,$webinar_id,$data_no); }*/ return $data_to_return; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request, $webinarId) { ini_set("max_execution_time", 0); try { $webinar = Webinar::find($webinarId); $webinar_uuid = hashWebinar($webinarId); $user_id = Auth::user()->id; $subscribers_lists = $webinar->subscribers_lists()->get(); $webinar_signup_subscribers_lists = $webinar->signup_subscribers_lists()->get(); $input = $request->all(); if (count($subscribers_lists) > 0) { $subject = $input['subject']; $body = $input['content']; $smtp_method = $input['smtp_method'][0]; $setting = Setting::whereName('custom_domain')->where('customer_id', '=', $user_id)->first(); if (!$setting) { return redirect()->back()->with("error", "Custom Domain is not Set."); } $smtp = Smtp::find($smtp_method); if (!$smtp) { return redirect()->back()->with("error", "No SMTP Method Found"); } $custom_domain = $setting->value; config(["mail.driver" => "smtp", "mail.host" => $smtp->host, "mail.port" => $smtp->port, "mail.from.address" => $smtp->from_email, "mail.from.name" => $smtp->from_name, "mail.encryption" => $smtp->protocol, "mail.username" => $smtp->username, "mail.password" => $smtp->password]); // General Subscribers List if ($subscribers_lists) { foreach ($subscribers_lists as $subscriber_list) { $subscribers = $subscriber_list->activeSubscribers()->get(); if (count($subscribers) > 0) { foreach ($subscribers as $subscriber) { $subscriber_hash = $subscriber->uuid; $subscriber_name = $subscriber->first_name . ' ' . $subscriber->last_name; $to_email = $subscriber->email; $webinar_url = "http://" . $custom_domain . "/webinar/" . $webinar_uuid . "/" . $subscriber_hash; $emailData = ['body' => $body, 'subscriber_name' => $subscriber_name, 'webinar_url' => $webinar_url]; Mail::send('emails.webinar_invite_email', $emailData, function ($message) use($subject, $to_email, $subscriber_name) { $message->subject($subject); $message->from('*****@*****.**', 'Webinar Admin'); $message->to($to_email, $subscriber_name); }); } } } } // Send Email to Webinar Specific Subscribers if ($webinar_signup_subscribers_lists) { foreach ($webinar_signup_subscribers_lists as $subscriber_list) { $subscribers = $subscriber_list->activeSubscribers()->get(); if (count($subscribers) > 0) { foreach ($subscribers as $subscriber) { echo $subscriber->id . "<br/>"; $subscriber_hash = $subscriber->uuid; $subscriber_name = $subscriber->first_name . ' ' . $subscriber->last_name; $to_email = $subscriber->email; $webinar_url = "http://" . $custom_domain . "/webinar/" . $webinar_uuid . "/" . $subscriber_hash; $emailData = ['body' => $body, 'subscriber_name' => $subscriber_name, 'webinar_url' => $webinar_url]; Mail::send('emails.webinar_invite_email', $emailData, function ($message) use($subject, $to_email, $subscriber_name) { $message->subject($subject); $message->to($to_email, $subscriber_name); }); } } } } } return redirect()->back()->with("status", "Mail Sent Succesfully"); } catch (\Exception $e) { } return redirect()->back(); }