本文整理汇总了PHP中app\models\Customer::onlyTrashed方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::onlyTrashed方法的具体用法?PHP Customer::onlyTrashed怎么用?PHP Customer::onlyTrashed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Customer
的用法示例。
在下文中一共展示了Customer::onlyTrashed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
public function login()
{
$validator = \Validator::make($this->request->all(), ['mobile' => 'required', 'password' => 'required']);
$account = $this->request->get('mobile');
//查询用户是否被删除
$del_user_user_name = Customer::onlyTrashed()->where('user_name', $account)->first();
$del_user_mobile = Customer::onlyTrashed()->where('mobile', $account)->first();
if ($del_user_user_name || $del_user_mobile) {
return return_rest('0', array('token' => '', 'customer' => array('id' => '', 'avatar' => '', 'type' => '', 'nickname' => '', 'name' => '', 'user_name' => '', 'mobile' => '')), '您已被移出!');
}
$password = $this->request->get('password');
$credentials_mobile = array('mobile' => $account, 'password' => $password);
$credentials_user_name = array('user_name' => $account, 'password' => $password);
$token = \JWTAuth::attempt($credentials_mobile) ? \JWTAuth::attempt($credentials_mobile) : \JWTAuth::attempt($credentials_user_name);
if (!$token) {
// $validator->after(function ($validator) {
// //$validator->errors()->add('error_msg', '用户名或密码错误');
// return $this->errorBadRequest(return_rest('0','','用户名或密码错误','10021'));
// });
return return_rest('0', array('token' => '', 'customer' => array('id' => '', 'avatar' => '', 'type' => '', 'nickname' => '', 'name' => '', 'user_name' => '', 'mobile' => '')), '用户名或密码错误');
}
if ($validator->fails()) {
//return $this->errorBadRequest($validator->messages());
$messages = $validator->messages();
$mobiles = $messages->get('mobile');
foreach ($mobiles as $mobile) {
if ($mobile == 'The selected mobile is invalid.') {
return $this->errorBadRequest(return_rest('0', '', '手机号码未注册'));
}
}
return return_rest('0', array('token' => '', 'customer' => array('id' => '', 'avatar' => '', 'type' => '', 'nickname' => '', 'name' => '')), '请按照规则输入手机号码');
}
//登录成功 获取用户信息
$customer = Customer::select('id', 'type', 'name', 'nickname', 'avatar', 'user_name', 'mobile')->where('user_name', $this->request->get('mobile'))->orWhere('mobile', $this->request->get('mobile'))->first();
return return_rest('1', compact('token', 'customer'), '登陆成功');
}