Esempio n. 1
0
 /**
  * Dispatches Mailchimp mailing
  *
  * @param MailingNode $mailing
  * @param MailingList $list
  */
 public function dispatchMailchimpMailing(MailingNode $mailing, MailingList $list)
 {
     $client = $this->getNewMailchimpGuzzleClient();
     $mailingId = $mailing->getExternalId($list->getKey());
     if ($this->isMailchimpCampaignUpdateable($client, $mailingId)) {
         $this->makeUpdateMailchimpCampaignRequest($client, $mailingId, $mailing, $list);
     } else {
         $response = $this->makeCreateMailchimpCampaignRequest($client, $mailing, $list);
         $mailingId = $response->json()['id'];
         $mailing->setExternalId($list->getKey(), $mailingId);
     }
     $this->makeUpdateMailchimpCampaignContentRequest($client, $mailingId, $mailing, $list);
 }
 /**
  * Creates a form for associating lists
  *
  * @param int $id
  * @param Model $model
  * @param string $resourceMultiple
  * @return \Kris\LaravelFormBuilder\Form
  */
 protected function getAddListForm($id, Model $model, $resourceMultiple)
 {
     $form = $this->form('Reactor\\Html\\Forms\\MailingLists\\AddMailingListForm', ['url' => route('reactor.' . $resourceMultiple . '.lists.associate', $id)]);
     $choices = MailingList::all()->diff($model->lists)->pluck('name', 'id')->toArray();
     $form->modify('list', 'select', ['choices' => $choices]);
     return [$form, count($choices)];
 }
Esempio n. 3
0
 /**
  * Unlink a list from subscriber
  *
  * @param int $id
  * @return MailingList
  */
 public function dissociateList($id)
 {
     return $this->lists()->detach(MailingList::findOrFail($id));
 }
Esempio n. 4
0
 /**
  * Checks if a member is subscribed to a list
  *
  * @param Subscriber $subscriber
  * @param MailingList $list
  */
 protected function isMemberSubscribedTo(Subscriber $subscriber, MailingList $list)
 {
     return $subscriber->lists->contains($list->getKey());
 }
 /**
  * List the specified resource fields.
  *
  * @param int $id
  * @return Response
  */
 public function mailings($id)
 {
     $mailing_list = MailingList::findOrFail($id);
     $mailings = $mailing_list->mailings()->sortable()->paginate();
     return $this->compileView('mailing_lists.mailings', compact('mailing_list', 'mailings'), trans('mailings.title'));
 }
Esempio n. 6
0
 /**
  * Dispatches the mailing
  *
  * @param MailingService $mailingService
  * @param int $id
  * @param int $list
  * @return response
  */
 public function dispatchMailing(MailingService $mailingService, $id, $list)
 {
     $this->authorize('EDIT_MAILINGS');
     $mailing = MailingNode::findOrFail($id);
     $list = MailingList::findOrFail($list);
     // Before this we are in the reactor theme by default
     Theme::set(config('themes.active_mailings'));
     if ($list->type === 'mailchimp') {
         $mailingService->dispatchMailchimpMailing($mailing, $list);
     } else {
         $mailingService->dispatchDefaultMailing($mailing, $list);
     }
     $this->notify('mailings.dispatched', 'dispatched_mailing', $mailing);
     return redirect()->back();
 }