问题描述
我不是后端专家。我这里有notifications
表的一些列,这些列已由Laravel中的多态关系使用。
+----+------------------+----------------+
| id | sendto_type | sendto_id |
+----+------------------+----------------+
| 1 | App\User | 1 |
| 2 | App\User | 2 |
| 3 | App\Station | 1 |
| 4 | App\Station | 2 |
+----+------------------+----------------+
我想获取具有属性“ App \ User”的列sendto_type
,它是使用Laravel中的多态关系制成的,并从名为users
的表派生而来。我还使用了sendto_id
与users
表中的关系。甚至有可能吗,如果可以,我该怎么做。
我尝试查询SELECT * FROM通知,其中sendto_type =“ App \ User”。成功,但未返回任何结果。请帮忙。
解决方法
您可能需要在查询中转义该\
,因为它通常用作修饰符。另外,请使用单引号而不是双引号。
WHERE sendto_type = 'App\\User'