public function create() { $aMate = Mate::create(['from_user_id' => Input::get('from_user_id'), 'to_user_id' => Input::get('to_user_id'), 'status' => Mate::MATE_STATUS_ADDED_BY_USER]); if ($aMate) { return response()->json(['status' => true, 'message' => "Successfully requested to be a mate", 'mate' => json_encode($aMate)]); } else { return response()->json(['status' => false, 'message' => "Something went wrong. Please try again"]); } }
public function register() { $email = Input::get('email'); $nickname = Input::get('nickname'); if (Mate::where('email', '=', $email)->count() != 0) { return 'email_used'; } $mate = Mate::create(['email' => $email, 'password' => Input::get('password'), 'nickname' => $nickname, 'school' => Input::get('school'), 'major' => Input::get('major'), 'schoolid' => input::get('schoolid'), 'majorid' => input::get('majorid'), 'region' => input::get('region'), 'inform' => false, 'lati' => Input::get('lati'), 'longi' => Input::get('longi')]); $activecode = md5($email . strtotime($mate->register)); $mate->activecode = $activecode; $mate->save(); $id = $mate->id; Mail::send('register', compact(['activecode', 'nickname', 'id']), function ($message) use($email) { $message->to($email, explode('@', $email)[0])->subject('欢迎注册'); }); return $id; }