Я застрял с ошибкой в запросе Eloquent
.
Мой запрос:
$mtd_hits = Usage::selectRaw("
SUM(table_hits) AS hits,
")
->where('user_id', '=', $user->id)
->whereBetween('created_at', [$from_date, $to_date])
->first();
В моем Usage
классе:
public $timestamps = true;
protected $dates = ['created_at', 'updated_at'];
Мои $from_date
и $to_date
являются Carbon
экземплярами:
$from_date
Carbon @1556323200 {#1416 ▼
date: 2019-04-27 00:00:00.0 UTC (+00:00)
}
$to_date
Carbon @1558915200 {#1622 ▼
date: 2019-05-27 00:00:00.0 UTC (+00:00)
}
По моему запросу не удается с:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from `usage` where `user_id` = ? and `created_at` between ? and ? limit 1' at line 3
(SQL: select SUM(table_hits) AS hits, from `usage` where `user_id` = 2 and `created_at` between 2019-04-27 00:00:00 and 2019-05-27 00:00:00 limit 1)
Заранее извиняюсь, если это глупый вопрос.