SELECT mir_notifications.* FROM mir_notifications LEFT JOIN mir_users_notification ON mir_notifications.id=mir_users_notification.notif_id WHERE (mir_notifications.notfication_type = 2 AND mir_users_notification.user_id=2) OR (mir_notifications.notification_type = 0)
产品有关系'类别'类别表和类别表有列' name'。我试图以这种方式访问该名称,但失败了。虽然价格没有问题。
$show=Product::where(['product_id'=>$id])->first();
if($show)
{
echo json_encode(array('status' => TRUE, 'show'=>$show); die;
}
:
ajax and javascripts
答案 0 :(得分:1)
您需要确保从SQL加载关系,并随变量一起返回。
$show=Product::where(['product_id'=>$id])->with('category')->first();