本文整理汇总了PHP中app\models\User::whereRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP User::whereRaw方法的具体用法?PHP User::whereRaw怎么用?PHP User::whereRaw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::whereRaw方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bellyButton
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));
}
示例2: anyLogin
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());
}
示例3: getFightersFor
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;
}
示例4: index
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');
}
}
示例5: login
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);
}
}
示例6: search
/**
* 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);
}