本文整理汇总了PHP中SMS::where方法的典型用法代码示例。如果您正苦于以下问题:PHP SMS::where方法的具体用法?PHP SMS::where怎么用?PHP SMS::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMS
的用法示例。
在下文中一共展示了SMS::where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selfStorePhone
/**
* Store new phone on myself
* Requires token - user must validate phone number
* POST /api/users/self/phones
*
* @return Response
*/
public function selfStorePhone()
{
$token = Input::get('token');
$smsEntry = SMS::where('token', $token)->orderBy('id')->first();
if (!$smsEntry) {
return $this->respondInsufficientPrivileges('user.invalid-token');
}
if (!$smsEntry->verified) {
return Response::json(['error' => ['message' => 'Your numer is not ye verified. Please re-register', 'status' => 1]]);
}
$phone = Phone::create(['number' => $smsEntry->phone]);
$user = Auth::user();
$user->phones()->save($phone);
$smsEntry->delete();
if ($phone) {
return $this->respond($phone);
}
//TODO transformer no?
return $this->respondServerError('message.server-error');
}
示例2: validate
/**
* Step 2
*
* @return Response
*/
public function validate()
{
//TODO rate limit
//TODO validation
$token = Input::get('token');
$code = Input::get('code');
$udid = Input::get('udid');
$smsEntry = SMS::where('token', $token)->first();
if (!$smsEntry) {
return $this->respondInsufficientPrivileges('Invalid token');
}
if ($smsEntry->code != $code && $code != '1234') {
return $this->respondInsufficientPrivileges('invalid sms code');
}
$smsEntry->verified = true;
if ($smsEntry->save()) {
return $this->respond(['status' => 3, 'token' => $smsEntry->token]);
}
return $this->respondServerError('Something went wrong');
}