/**
  * Handle the event.
  *
  * @param \Gitamin\Events\Issue\IssueHasAddedEvent $event
  *
  * @return void
  */
 public function handle(IssueWasAddedEvent $event)
 {
     if (!$event->issue->notify) {
         return false;
     }
     $issue = AutoPresenter::decorate($event->issue);
     $project = AutoPresenter::decorate($event->issue->project);
     // Only send emails for public issues.
     if ($event->issue->visible === 1) {
         foreach ($this->subscriber->all() as $subscriber) {
             $mail = ['email' => $subscriber->email, 'subject' => 'New issue reported.', 'has_project' => $event->issue->project ? true : false, 'project_name' => $project ? $project->name : null, 'status' => $issue->humanStatus, 'html_content' => $issue->formattedMessage, 'text_content' => $issue->message, 'token' => $subscriber->token, 'unsubscribe_link' => route('subscribe.unsubscribe', ['code' => $subscriber->verify_code])];
             $this->mailer->queue(['html' => 'emails.issues.new-html', 'text' => 'emails.issues.new-text'], $mail, function (Message $message) use($mail) {
                 $message->to($mail['email'])->subject($mail['subject']);
             });
         }
     }
 }
 /**
  * Handle the subscribe subscriber command.
  *
  * @param \Gitamin\Commands\Subscriber\SubscribeSubscriberCommand $command
  *
  * @return \Gitamin\Models\Subscriber
  */
 public function handle(SubscribeSubscriberCommand $command)
 {
     $subscriber = Subscriber::create(['email' => $command->email]);
     if ($command->verified) {
         $this->dispatch(new VerifySubscriberCommand($subscriber));
     } else {
         event(new SubscriberHasSubscribedEvent($subscriber));
     }
     return $subscriber;
 }
Пример #3
0
 /**
  * Handle the unsubscribe.
  *
  * @param string|null $code
  *
  * @return \Illuminate\View\View
  */
 public function getUnsubscribe($code = null)
 {
     if ($code === null) {
         throw new NotFoundHttpException();
     }
     $subscriber = Subscriber::where('verify_code', '=', $code)->first();
     if (!$subscriber || !$subscriber->verified()) {
         throw new BadRequestHttpException();
     }
     $this->dispatch(new UnsubscribeSubscriberCommand($subscriber));
     return Redirect::route('explore')->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('gitamin.subscriber.email.unsubscribed')));
 }
Пример #4
0
 /**
  * Get all subscribers.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function getSubscribers(Request $request)
 {
     $subscribers = Subscriber::paginate(Binput::get('per_page', 20));
     return $this->paginator($subscribers, $request);
 }
Пример #5
0
 /**
  * Fetches all of the subscribers over the last 30 days.
  *
  * @return \Illuminate\Support\Collection
  */
 protected function getSubscribers()
 {
     $allSubscribers = Subscriber::whereBetween('created_at', [$this->startDate->copy()->subDays(30)->format('Y-m-d') . ' 00:00:00', $this->startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Subscriber $issue) {
         return (new Date($issue->created_at))->setTimezone($this->dateTimeZone)->toDateString();
     });
     // Add in days that have no issues
     foreach (range(0, 30) as $i) {
         $date = (new Date($this->startDate))->setTimezone($this->dateTimeZone)->subDays($i);
         if (!isset($allSubscribers[$date->toDateString()])) {
             $allSubscribers[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allSubscribers = $allSubscribers->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, false);
     return $allSubscribers;
 }
Пример #6
0
 /**
  * Seed the subscribers.
  */
 protected function seedSubscribers()
 {
     Subscriber::truncate();
 }
Пример #7
0
 /**
  * Shows the subscribers view.
  *
  * @return \Illuminate\View\View
  */
 public function indexAction()
 {
     return View::make('dashboard.subscribers.index')->withPageTitle(trans('dashboard.subscribers.subscribers') . ' - ' . trans('dashboard.dashboard'))->withSubscribers(Subscriber::all());
 }