仅获取专利数据数据 child 关系中的数据为空?
Get patents data data only child has empty data in relationship?
我有一个像下面这样的集合。我需要获取那些没有上传文档的用户。现在从关系中,我该如何获取这个?
[0] => Array
(
[id] => 2
[user_id] => 8
[referred_by] =>
........
[user_documents] =>
)
[1] => Array
(
[id] => 3
[user_id] => 9
[referred_by] =>
[reference_id] => NM1100008
.......
[user_documents] => Array
(
[id] => 1
[customer_id] => 3
[doc_type] => 1
[document] => N8xFORsPpkTayTQ9Ihyz0ly7QM62TJHxvHhSFQSN.png
[admin_comment] =>
[approve_status] => approve
[other_gov_id] =>
[doc_no] => 1
[created_at] => 2020-04-04 12:39:12
[updated_at] => 2020-04-06 13:57:01
[deleted_at] =>
)
)
我只想在 user_documents 为空时获取行。。获取那些没有上传文件到系统的用户。
[user_documents] =>
提前致谢。
根据您设置关系的方式,这样的事情应该可行:
User::doesntHave('documents')->get();
您可以使用 laravel querying-relationship-absence
$users= User::doesntHave('user_documents')->get();
我有一个像下面这样的集合。我需要获取那些没有上传文档的用户。现在从关系中,我该如何获取这个?
[0] => Array
(
[id] => 2
[user_id] => 8
[referred_by] =>
........
[user_documents] =>
)
[1] => Array
(
[id] => 3
[user_id] => 9
[referred_by] =>
[reference_id] => NM1100008
.......
[user_documents] => Array
(
[id] => 1
[customer_id] => 3
[doc_type] => 1
[document] => N8xFORsPpkTayTQ9Ihyz0ly7QM62TJHxvHhSFQSN.png
[admin_comment] =>
[approve_status] => approve
[other_gov_id] =>
[doc_no] => 1
[created_at] => 2020-04-04 12:39:12
[updated_at] => 2020-04-06 13:57:01
[deleted_at] =>
)
)
我只想在 user_documents 为空时获取行。。获取那些没有上传文件到系统的用户。
[user_documents] =>
提前致谢。
根据您设置关系的方式,这样的事情应该可行:
User::doesntHave('documents')->get();
您可以使用 laravel querying-relationship-absence
$users= User::doesntHave('user_documents')->get();