示例#1
0
 /**
  * Creates new invite
  * @param  string $email
  * @return mixed
  */
 public function store($email)
 {
     $auth_user_id = Auth::user()->id;
     $auth_user_email = Auth::user()->email;
     $auth_user_name = Auth::user()->name;
     $invite = new Invite();
     $invite->user_id = $auth_user_id;
     $invite->email = $email;
     $invite->save();
 }
 public function postInvite(Request $request)
 {
     // check if already invited or not
     if (Invite::where('email', $request->email)->first() == null) {
         $user = Auth::user();
         //create new invite
         $invite = new Invite();
         $invite->email = $request->email;
         $invite->user()->associate($user);
         $invite->save();
         $data = ['title' => $user->name . ' invited you to join CocaCola Rewards!', 'content' => 'Join us right now by signing up. Start acquiring points and claim your rewards!', 'email' => $invite->email];
         //send mail to invited person
         Mail::send('emails.invite', $data, function ($message) use($data) {
             $message->to($data['email']);
             $message->subject('Invite to CocaCola Rewards');
         });
     }
     return redirect('dashboard');
 }