/** * Unsubscribe from a LaSalleCRM email list * * @param $token */ public function unsubscribe($token) { // Does the token exist in the list_unsubscribe_token database table? if (!$this->model->isTokenValid($token)) { return view('lasallecrmlistmanagement::subscribe-unsubscribe-list.token_invalid', ['title' => 'Invalid Unsubscribe Token']); } $emailID = $this->model->getEmailIdByToken($token); $listID = $this->model->getListIdByToken($token); // email address $email = $this->emailRepository->getEmailByEmailId($emailID); // list's name $listName = $this->listRepository->getListnameByListId($listID); // Delete all list_unsubscribe_token records for this email_id and list_id $this->model->deleteAllTokensForListIDandEmailID($listID, $emailID); // un-enabled (ie, disable) the list_email database record for this email_id and list_id $this->list_EmailRepository->enabledFalse($emailID, $listID); return view('lasallecrmlistmanagement::subscribe-unsubscribe-list.unsubscribe_success', ['title' => 'Unsubscribe Successful', 'email' => $email, 'listName' => $listName]); }
/** * Get the name of the list for a given list ID * * @param int $listID The "id" field of the "email_list" db table * @return string */ public function getListnameByListId($listID) { return $this->listRepository->getListnameByListId($listID); }