private function getRecipients(Subscriber $subscriber) { return array_only($subscriber->toArray(), array('name', 'email')); }
public function updateNextLesson($id) { try { $subscriber = Subscriber::with('course')->with('next_lesson')->find($id); if (!$subscriber) { throw new Exceptions\NotFoundException('Subscriber not found'); } $nextLesson = $subscriber->nextLesson(); $subscriber->next_lesson_id = $nextLesson ? $nextLesson->id : null; $subscriber->next_lesson_on = $nextLesson ? $nextLesson->nextOn() : null; $subscriber->completed_at = is_null($nextLesson) ? Carbon::now() : null; // if there's no next lesson to schedule, we will mark it as completed $subscriber->save(); return $subscriber; } catch (Exceptions\NotFoundException $e) { throw $e; } catch (MassAssignmentException $e) { throw $e; } catch (\Exception $e) { throw new Exceptions\InternalException(); } }