Example #1
0
 public function bellyButton()
 {
     $users = User::whereRaw('MONTH(birthday) =' . date('m'))->whereRaw('DAY(birthday) =' . date('d'))->where('membership_expires', '>=', date('Y-m-d'))->get();
     $data = array();
     foreach ($users as $user) {
         $data[] = array('recipient' => $user->email, 'first_name' => $user->first_name);
     }
     $this->cron->sendBellyButtonBirthdayCards($data);
     return view('cron.belly-button-birthdays', array('users' => $users));
 }
 public function anyLogin()
 {
     $all = request()->all();
     if (isset($all['name']) && isset($all['psw'])) {
         $user = User::whereRaw('name = ?', [$all['name']])->first();
         if (isset($user) && $user->psw == $all['psw']) {
             session(['currentUser' => $user]);
             return redirect()->action('Bupt\\UserController@anyIndex');
         }
     }
     return view('bupt.user.login', request()->all());
 }
Example #3
0
 public function getFightersFor($gender, $age_group, $belt, $weight)
 {
     $min_age = $this->age_categories[$age_group][0];
     $max_age = $this->age_categories[$age_group][1];
     $min_birthday = Helper::calculateBirthday($min_age);
     $max_birthday = Helper::calculateBirthday($max_age);
     $results = User::whereRaw('gender = ? AND belt = ? AND weight = ? AND dob BETWEEN ? AND ? ', array($gender, $belt, $weight, $max_birthday, $min_birthday))->orderBy('dob')->get();
     // $queries = DB::getQueryLog();
     // $last_query = end($queries);
     // var_dump($results->all(), $last_query, $age_group);
     return $results;
 }
 public function index()
 {
     $user = User::whereRaw('tel = ? and password = ?', array(Input::get('tel'), md5(Input::get('password'))))->first();
     if ($user) {
         $token = uniqid();
         Session::put('token', $token);
         Session::put('uid', $user->id);
         $user->school;
         unset($user->choolId);
         return array('code' => 0, 'data' => $user);
     } else {
         return array('code' => 1, 'data' => 'tel or psw error');
     }
 }
Example #5
0
 public function login()
 {
     $user = User::whereRaw('tel = ? and password = ?', array(Input::get('tel'), md5(Input::get('password'))))->first();
     if ($user) {
         //             if ($user->nickname == '' || $user->schoolId == '' || $user->avatarUrl == ''){
         //                 return $this->outputError('请完善用户信息', 2);
         //             }
         Session::put('uid', $user->_id);
         $user->school;
         unset($user->schoolId);
         $user->tags;
         return $this->output($user);
     } else {
         return $this->outputError('tel or psw error', 2);
     }
 }
 /**
  * Return a json search result.
  *
  * @var $search
  * @return json
  */
 public function search($search)
 {
     $usersL = [];
     $users = User::whereRaw("name LIKE '%" . $search . "%' OR email LIKE '%" . $search . "%'")->take(10)->get();
     foreach ($users as $id => $user) {
         $usersL[] = ['id' => $user->id, 'name' => $user->name, 'email' => $user->email, 'score' => $user->score->value];
     }
     return response()->json($usersL);
 }