2
嗨如何检查雄辩多态关系已经存在?如何检查Eloequent多态的关系?
例如,我要防止在附件表中获取存储与同upload_id,attachable_id和attachable_type数据(参见高亮)
我所尝试,但并没有得到相关的正确计数存在:
//get count of attachment
$application->has('attachments')->count()
嗨如何检查雄辩多态关系已经存在?如何检查Eloequent多态的关系?
例如,我要防止在附件表中获取存储与同upload_id,attachable_id和attachable_type数据(参见高亮)
我所尝试,但并没有得到相关的正确计数存在:
//get count of attachment
$application->has('attachments')->count()
您只需查询该upload_id
相关附件:
$hasAttachments = $application->attachments()
->where('upload_id', $upload_id)
->count() > 0;
感谢它的工作为什么我不能想到使用这个基本检查:( – cyberfly