我正在使用Laravel在一个简单的仪表板上工作,该仪表板主要跟踪访客信息。 我无法编写laravel查询生成器或雄辩的代码
如果有人可以提供帮助,我将坚持获取唯一的数据。
答案 0 :(得分:2)
只需编写原始查询并使用它们。
今天:select distinct id, ip_address, browser from table_name where DATE(visited_time) = CURDATE();
月份:select distinct id, ip_address, browser from table_name where month(visited_time) = month(NOW()) and year(visited_time) = year(NOW());
周:select distinct id, ip_address, browser from table_name where week(visited_time) = week(NOW()) and year(visited_time) = year(NOW());
年份:select distinct id, ip_address, browser from table_name where year(visited_time) = year(NOW());