这里有一个酒店项目,每家酒店都有一个管理员。
我所做的:
在用户类型表中,厨师、经理、酒店等不同类型的用户
如果用户类型是酒店,则意味着它是该酒店的管理员。现在,对于每一个CRUD和其他功能,我得到了这样的旅馆id
$hotel_id = \Auth::user()->hotel_id;
并在每个查询(like get user, save user, get invoice,set invoice,check food etc)中检查此like get user, save user, get invoice,set invoice,check food etc。
这样做对吗?
我试图从下面的数据库中返回官员的名字,他们管理的酒店和他们参考的匹配数量(参见下面的关系图)。
我尝试了以下方法,但不起作用:
select officials.name as Official,
hotels.name as Hotel, -- hotel the official manages
count (case when officials.name = matches.referee then 1 else null end) as Matchesrefereed
from officials
left join hotels
on officials.staffid = ho