. */ namespace Poniverse\Ponyfm\Http\Controllers; use App; use DB; use Poniverse\Ponyfm\Models\Email; use Poniverse\Ponyfm\Models\EmailSubscription; class NotificationsController extends Controller { /** * @param $emailKey * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function getEmailClick($emailKey) { /** @var Email $email */ $email = Email::findOrFail($emailKey); DB::transaction(function() use ($email) { $email->emailClicks()->create(['ip_address' => \Request::ip()]); $email->notification->is_read = true; $email->notification->save(); }); return redirect($email->getActivity()->url); } public function getEmailUnsubscribe($subscriptionKey) { $subscription = EmailSubscription::findOrFail($subscriptionKey); $subscription->delete(); return 'Unsubscribed!'; } }