您好我有2个表数字和number_details有2个型号Number和Number_details。这是我的代码
数字模型
public function number() {
return $this->hasOne('Number');
}
NumberDetails模型
public function store(Request $request){
$numberDetails = new NumberDetails;
$numberDetails->number_id =//how to get id ;
$numberDetails->save();
}
NumberController
$('#login').click ( function() {
$.ajax({
type: "POST",
url: 'login.php',
data: $('#loginform').serialize(),
dataType: 'json',
success: function(data) {
// Check the result from data
if (data.result == 'success') {
$('#message').html('success');
} else {
$('#message').html('fail');
}
},
error: function(d) {
$('#message').html('error');
}
});
return false;
})
答案 0 :(得分:0)
更新:当我尝试使用时:
$numberDetails->number_id = Number::find(id); Trying to get property of non-object