Created
May 18, 2018 11:49
-
-
Save aynm142/9b851861d8fce5bb44ff92bc530c4b96 to your computer and use it in GitHub Desktop.
user.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function activateCode(Request $request) | |
{ | |
$code = $request->get('promo_code'); | |
if ($this->user->activation_code || $this->user->promo_code_first == $code || $this->user->promo_code_second == $code) { | |
return response()->json([], 405); | |
} | |
$referral = User::wherePromoCodeFirst($code)->first(); | |
$referral_second = User::wherePromoCodeSecond($code)->first(); | |
if ($referral || $referral_second) { | |
$this->user->activation_code = $code; | |
$this->user->referrer_id = ($referral) ? $referral->id : $referral_second->id | |
$this->user->save(); | |
} else { | |
return response()->json([], 404); | |
} | |
return response()->json([], 200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment