/** * Store a newly created resource in storage. * * @return Response */ public function store() { // Fetch all request data. $data = \Input::only('email', 'referer'); // Build the validation constraint set. $rules = array('email' => array('required', 'min:3', 'max:100', 'unique:beta_newsletters'), 'referer' => array('alpha_num')); // Create a new validator instance. $validator = \Validator::make($data, $rules); if ($validator->passes()) { $beta = new Beta(); $beta->email = \Input::get('email'); if (\Config::get('betaup::config.email_confirmation') === 'true') { $activation_code = uniqid(rand(1000, 6000), true); $beta->activation_code = $activation_code; \Mail::send('betaup::beta.email.activate', array('activation_code' => $activation_code), function ($message) { $message->to(\Input::get('email'))->subject('Welcome!'); }); } if (\Config::get('betaup::config.activated_by_default') === 'true') { $beta->activated = '1'; $beta->activated_at = new \DateTime(); } $beta->refer = uniqid(); $beta->save(); if ($referer = \Input::get('referer')) { \Betaup::karmaUp($referer, '1'); } return \Redirect::to(\Config::get('betaup::config.uri'))->with('global_success', 'You have been signed up successfuly!'); } return \Redirect::to(\Config::get('betaup::config.uri'))->withInput()->withErrors($validator)->with('message', 'Validation Errors!'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // Fetch all request data. $data = Input::only('email', 'name'); // Build the validation constraint set. $rules = array('name' => array('alpha_num'), 'email' => array('required', 'min:3', 'max:100', 'unique:betas')); // Create a new validator instance. $validator = Validator::make($data, $rules); if ($validator->passes()) { $beta = new Beta(); $beta->email = Input::get('email'); $beta->name = Input::get('name'); $beta->save(); return Redirect::to('/')->with('global_success', 'true'); } return Redirect::to('/')->withInput()->withErrors($validator)->with('message', 'Validation Errors!'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // Fetch all request data. $data = Input::only('email'); // Build the validation constraint set. $rules = array('email' => array('required', 'min:3', 'max:100', 'unique:beta_newsletters')); // Create a new validator instance. $validator = Validator::make($data, $rules); if ($validator->passes()) { $beta = new Beta(); $beta->email = Input::get('email'); $activation_code = uniqid(rand(1000, 6000), true); $beta->activation_code = $activation_code; Mail::send('beta.activate', array('activation_code' => $activation_code), function ($message) { $message->to(Input::get('email'))->subject('Welcome!'); }); $beta->save(); return Redirect::to('/beta')->with('global_success', 'You have been signed up successfully! Confirmation link has been sent to given e-mail address.'); } return Redirect::to('/beta')->withInput()->withErrors($validator)->with('message', 'Validation Errors!'); }
/** * Request for a beta invite */ public function request() { // lets validate the email $validator = Validator::make(array('email' => Input::get('email')), array('email' => 'required|email|unique:beta')); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $beta_user = new Beta(); $beta_user->email = Input::get('email'); $beta_user->status = 0; $beta_user->save(); // Send the beta confirmation email sendBetaFollowUpMail(Input::get('email')); return Redirect::back()->with('success', "You are all set, your invitation will arrive soon."); }