Laravel 获取日、周、月、年的不同/唯一记录

Laravel Get Distinct / Unique Records of Day, Week, Month, Year

我正在使用 Laravel 开发一个简单的仪表板,它主要跟踪访问者信息。 我无法将 laravel 查询构建器或 eloquent 代码写入

这是我的数据库 table 列。

如果有人可以提供帮助,我将无法获取唯一数据。

只需编写原始查询并使用它们。

今天: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());