我是Laravel框架的新手,所以请耐心等待,我有两个表用户和received_pay表,挑战是我想首先检查receive_pay的电子邮件和receipt_number,如果他们在注册时与用户输入匹配如果它们匹配则创建新用户否则被拒绝,下面是我的表格详细信息
用户: id,username,email,remember_token,created_at,updated_at
received_pay: id,email,receipt_number
我的用户注册控制器代码是:
protected function create(array $data)
{
if (Received_pay::where('email', '=', Input::get('email'))->exists()) {
// user found
echo "user exist";
}
return User::create([
'username' => $data['username'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'token' => $data['token'],
]);
答案 0 :(得分:0)
只需更改
Received_pay::where('email', '=', Input::get('email'))->exists()
到
Received_pay::where('email', '=', Input::get('email'))->where('receipt_number', Input::get('receipt_number'))->exists()
您可以使用多个where()