public function index(Request $request) { if (Invite::where('code', '=', $request->code)->exists()) { if (Invite::where('code', $request->code)->first()->claimed == false) { return view('/invites/register'); } else { return view('home')->with('error', 'This code has been used.'); } return view('home')->with('error', 'This code does not exist.'); } }
/** * When the friend clicks the link in their email, * the user that invited them is rewarded * * @return mixed */ public function inviteClicked() { //find invite based on the token $invite = Invite::where('token', \Request::get('token'))->first(); if ($invite != null && !$invite->clicked) { //reward user when the link is clicked $this->pointService->inviteReward(\Request::get('user_id'), $invite->id); $invite->update(['clicked' => true]); } //determine the platform and set the url accordingly if (\Request::get('platform') == 'android') { $url = $this->googlePlayUrl; } else { $url = $this->appStoreUrl; } //redirect to googlePlay/appStore return \Redirect::to($url); }