Tip: use 3 backticks (```) or three tildes (~~~) around your code block to make it pretty-formatted. This backticks\tildes sequence should live in their own line.
For example:
```
if ($foo) return 'ok';
```
Or:
~~~
if ($foo) return 'ok';
~~~
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Can any body help me to convert this raw sql query to laravel query builder syntax
`` SELECT YEAR(matches.init_ts) AS YEAR , MONTH(matches.init_ts) AS MONTH, WEEK(matches.init_ts) AS WEEK , DAY(matches.init_ts) AS DAY , AVG(stat_value) AS avg_stat , player_id AS Id, 'player' AS NAME
FROM matches_stats
JOIN matches ON matches.id = matches_stats.match_id
WHERE player_id = 1
AND matches_stats.stat_type_id = 11
AND WEEK(matches.init_ts) = WEEK(NOW())
GROUP BY YEAR(matches.init_ts),MONTH(matches.init_ts),player_id,WEEK(matches.init_ts),DAY(matches.init_ts)
``
Please or to participate in this conversation.