/**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $fields = $request->except("_token");
     $subscribersList = SubscribersList::find($id);
     $subscribersList->update(['name' => $fields['name']]);
     return redirect()->back()->with('status', "Updated Successful.");
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $subscribers_lists = [['name' => "Internal", 'description' => "Internal stuffs only", 'user_id' => 3], ['name' => "bonus", 'description' => "Bonus people", 'user_id' => 1], ['name' => "Affiliates", 'description' => "For affiliates only.", 'user_id' => 3]];
     for ($i = 1; $i <= 15; $i++) {
         $webinar_subscribers_lists[] = ['name' => 'webinar_lists_' . $i, 'description' => 'This is a webinar subscriber list', 'user_id' => 1, 'webinar_id' => $i];
     }
     $subscribers_lists = array_merge($subscribers_lists, $webinar_subscribers_lists);
     foreach ($subscribers_lists as $list) {
         SubscribersList::create($list);
     }
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::resolver(function ($translator, $data, $rules, $messages) {
         return new CustomValidator($translator, $data, $rules, $messages);
     });
     Validator::extend('unique_subscribers_list_email', function ($attribute, $value, $parameters) {
         $subscribers_list_id = $parameters[0];
         $email = $parameters[1];
         $subscriberId = intval($parameters[2]);
         $subscriber = SubscribersList::find($subscribers_list_id)->subscribers()->where('email', $email)->first();
         return !$subscriber || $subscriber->id == $subscriberId;
     }, "There is already another subscriber with the email address in current list.");
 }
 /**
  * Stores bulk subscribers create request.
  *
  * @param  \Illuminate\Http\Request  $request
  */
 public function store(Request $request, $userId, $subscribersListId)
 {
     $subscribers = Input::get('subscribers');
     $list = SubscribersList::find($subscribersListId);
     foreach ($subscribers as $subscriber) {
         if ($list->subscribers()->where('email', $subscriber['email'])->count() == 0) {
             $subscriber['status'] = 'Active';
             $subscriber = Subscriber::create($subscriber);
             $subscriber->uuid = hashSubscriber($subscriber->id);
             $subscriber->save();
             $subscriber->subscribers_lists()->attach($subscribersListId);
         }
     }
 }
示例#5
0
 public function subscribers(Request $request)
 {
     $list_id = $request->list_id;
     $q = $request->q;
     if ($q != null) {
         $subscribers = SubscribersList::find($list_id)->subscribers()->where('email', 'like', '%' . $q . '%')->orderBy('created_at', 'desc')->take(50)->get();
         $this->data['subscribers'] = $subscribers;
     } else {
         $subscribers = SubscribersList::find($list_id)->subscribers()->orderBy('created_at', 'desc')->take(50)->get();
         $this->data['subscribers'] = $subscribers;
     }
     $this->data['list'] = SubscribersList::find($list_id);
     $this->data['num_subscribers'] = $subscribers = SubscribersList::find($list_id)->subscribers()->count();
     return view('manage.email.subscribers', $this->data);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $webinars = [];
     $users = [1, 2, 3];
     foreach ($users as $uid) {
         for ($i = 0; $i < 5; $i++) {
             $faker = Faker\Factory::create();
             $webinar = ['user_id' => $uid, 'title' => $faker->realText($faker->numberBetween(60, 80)), 'hosts' => $faker->realText($faker->numberBetween(60, 80)), 'share' => $faker->realText($faker->numberBetween(30, 50)), 'description' => $faker->realText($faker->numberBetween(120, 180)), 'starts_on' => $faker->dateTime($min = 'now'), 'duration' => rand(1, 4) . 'h', 'timezone' => 'EDT'];
             $webinar = Webinar::create($webinar);
             $hashedId = hashWebinar($webinar->id);
             $webinar->uuid = $hashedId;
             $webinar->save();
             $webinar->subscribers_lists()->attach(rand(1, 3));
             $webinar_subscriber_list = SubscribersList::whereWebinarId($webinar->id)->first();
             $webinar->signup_subscribers_lists()->attach($webinar_subscriber_list->id);
         }
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(WebinarStoreRequest $request, $userId)
 {
     $user_id = Auth::user()->id;
     $input = $request->input();
     $starts = trim(explode(',', $input['date_starts_on'])[1]) . ' ' . $input['time_starts_on'];
     $starts = Carbon::createFromFormat('d F Y h:i A', $starts)->toDateTimeString();
     $input['starts_on'] = $starts;
     $input['share'] = '';
     $input['streaming_server_code'] = '';
     $webinar = Webinar::create($input);
     $webinar->uuid = hashWebinar($webinar->id);
     foreach ($input['subscribers_lists'] as $listId) {
         $webinar->subscribers_lists()->attach($listId);
     }
     if (isset($input['excluded_subscribers_lists'])) {
         foreach ($input['excluded_subscribers_lists'] as $listId) {
             $webinar->excluded_subscribers_lists()->attach($listId);
         }
     }
     if (isset($input['panelists'])) {
         foreach ($input['panelists'] as $panelist) {
             $webinar->panelists()->attach($panelist);
         }
     }
     $webinar->save();
     if (isset($input["webinar_subscriber_list_name"])) {
         $webinar_subscriber = ["name" => $input["webinar_subscriber_list_name"], "description" => $input["webinar_subscriber_list_description"], "user_id" => $user_id, "webinar_id" => $webinar->id];
         $list = SubscribersList::create($webinar_subscriber);
         $webinar->signup_subscribers_lists()->attach($list->id);
     }
     \Auth::user()->webinars()->save($webinar);
     return redirect()->back()->with("status", "Webinar has been created successfully");
 }
示例#8
0
 public function send_more_list(Request $request)
 {
     $cam = EmailCampaign::find($request->cam_id);
     $lists = explode(',', $request->list_id);
     $lists_array = array();
     $list_ids = array();
     foreach ($lists as $l) {
         $t = explode('=', $l);
         $lists_array[] = SubscribersList::find($t[1]);
         $list_ids[] = $t[1];
         $cam->subscribers_lists()->attach($t[1]);
     }
     $take = 5;
     $delay = 40;
     $total_mails = 0;
     foreach ($lists_array as $l) {
         $total_mails += $l->subscribers()->count();
     }
     $nums_jobs = $total_mails / $take;
     for ($i = 0; $i < $nums_jobs; $i++) {
         $job = (new SendMarketingEmail($cam, $list_ids, $i * $take, $take))->delay($i * $delay);
         $this->dispatch($job);
     }
     $cam->send_time = $cam->send_time + $nums_jobs * $delay;
     $cam->save();
     return redirect('manage/campaign?id=' . $cam->id);
 }