本文整理匯總了PHP中App\Http\Controllers\Controller::returnJson方法的典型用法代碼示例。如果您正苦於以下問題:PHP Controller::returnJson方法的具體用法?PHP Controller::returnJson怎麽用?PHP Controller::returnJson使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類App\Http\Controllers\Controller
的用法示例。
在下文中一共展示了Controller::returnJson方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postSendsms
public function postSendsms(Request $request)
{
$mobile = Input::get('mobile');
if (!preg_match("/1[3458]{1}\\d{9}\$/", $mobile)) {
// if(!preg_match("/^13\d{9}$|^14\d{9}$|^15\d{9}$|^17\d{9}$|^18\d{9}$/",$mobile)){
//手機號碼格式不對
return parent::returnJson(1, "手機號碼格式不對" . $mobile);
}
$data = DB::select("select * from members where lifestatus=1 and mobile =" . $mobile);
if (sizeof($data) > 0) {
return parent::returnJson(1, "手機號已注冊");
}
$checkCode = parent::get_code(6, 1);
Session::put("m" . $mobile, $checkCode);
$checkCode = Session::get("m" . $mobile);
Log::error("sendsms:session:" . $checkCode);
$msg = "尊敬的用戶:" . $checkCode . "是您本次的短信驗證碼,5分鍾內有效.";
// Input::get('msg');
$curl = new cURL();
$serverUrl = "http://cf.lmobile.cn/submitdata/Service.asmx/g_Submit";
$response = $curl->get($serverUrl . "?sname=dlrmcf58&spwd=ZRB2aP8K&scorpid=&sprdid=1012818&sdst=" . $mobile . "&smsg=" . rawurlencode($msg . "【投貸寶】"));
$xml = simplexml_load_string($response);
echo json_encode($xml);
//$xml->State;
// <CSubmitState xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">
// <State>0</State>
// <MsgID>1512191953407413801</MsgID>
// <MsgState>提交成功</MsgState>
// <Reserve>0</Reserve>
// </CSubmitState>
// <State>1023</State>
// <MsgID>0</MsgID>
// <MsgState>無效計費條數,號碼不規則,過濾[1:186019249011,]</MsgState>
// <Reserve>0</Reserve>
}
示例2: postLogin
public function postLogin(Request $request, Route $route)
{
Log::error('postlogin:');
//調用validate驗證前端數據
if (empty($request->get('name'))) {
return parent::returnJson(1, "用戶名不能為空");
}
if (empty($request->get('password'))) {
return parent::returnJson(1, "用戶名不能為空");
}
$credentials = $request->only('name', 'password');
Log::error('login:' . $request->get('name') . "password" . $request->get('password'));
//過濾掉前端數據,隻留下name和password
if ($this->auth->attempt($credentials, $request->has('remember'))) {
return parent::returnJson(0, "登錄成功");
}
return parent::returnJson(1, "用戶名或密碼錯誤");
//調用validate驗證前端數據
// $name = Input::get('name');
// $member->email = $member->name ."126.com";// Input::get('email');
// $password ='123456';// Hash::make(Input::get('password'));
// $password =Input::get('password');
Log::error("backendgetLogin: " . $name . $password);
// $this->validate($request, ['name'=> 'required', 'password'=> 'required']);
// $credentials = $request->only('name', 'password');//過濾掉前端數據,隻留下email和password
// if($this->auth->attempt(array( 'name'=>$name,'password' =>$password))) {
// if ($this->auth->attempt($credentials, $request->has('remember')))//重點就是這一個attempt方法,這個就是驗證用戶數據數據和數據庫數據作比較的流程
// {
// Log::error("getLogin1");
// return redirect()->intended("backend/home");//驗證通過則跳入主頁
// // return redirect()->intended($this->redirectPath());//驗證通過則跳入主頁
// }
// return redirect($request->back())//$this->loginPath())
// //withInput(),負責數據寫入session
// ->withInput($request->only('name', 'password'))//驗證失敗,即輸入數據和數據庫數據不一致,攜帶錯誤信息返回到登錄界麵
// ->withErrors([
// 'name'=> $this->getFailedLoginMessage(),
// ]);
}
示例3: postModifypwd
public function postModifypwd(Request $request)
{
//更新密碼
$array = ["password" => Hash::make($request->get('password'))];
if (!empty($request->get('mobile'))) {
if (Member::where('mobile', $request->get('mobile'))->update($array)) {
$member_log = new Member_log();
$member_log->ip = $request->getClientIp();
$member_log->memberid = Session::get('memberd');
$member_log->action = "forgetpwd";
$member_log->type = 1;
$member_log->save();
return parent::returnJson(0, "密碼修改成功");
}
} else {
if (Member::where('id', $this->auth->get()->id)->update($array)) {
$member_log = new Member_log();
$member_log->ip = $request->getClientIp();
$member_log->memberid = $this->auth->get()->id;
$member_log->action = "changepwd";
$member_log->type = 1;
$member_log->save();
return parent::returnJson(0, "密碼修改成功");
}
}
return parent::returnJson(1, "密碼修改失敗");
}
示例4: postAuthecompany
public function postAuthecompany(Request $request)
{
$cart = parent::movefile($request, "company");
if ($cart['status'] == 1) {
return parent::returnJson(1, $cart['msg']);
} else {
$cardnourl = $cart['msg'];
}
// $this->validate($request, ['itemname' => 'required|min:3', 'email' =>'required','no'=>'required']);
$member = new Member();
$member->id = $this->auth->get()->id;
$member->type = 2;
$member->authestatus = 1;
$member->cardnourl = $cardnourl;
$member->address = $request->get('address');
$member->addresscode = $request->get('addresscode');
$member->roletype = $request->get('roletype');
$member->itemname = $request->get('itemname');
$member->email = $request->get('email');
$member->cardno = $request->get('cardno');
$member->updatememberInfo($member->id, $member);
return parent::returnJson(0, "提交成功");
}