Convert my DB raw to Laravel Eloquent model
I have this code from a tutorial and i was wondering how can i convert it to laravel eloquent method because currently it is in DB raw method.
// $match = DiraChatLog::select(DB::raw("SUM(numberofview) as count"))
// ->orderBy("created_at")
// ->groupBy(DB::raw("year(created_at)"))
// ->get()->toArray();
// $match = array_column($match, 'count');
// $missing = DiraChatLog::select(DB::raw("SUM(numberofclick) as count"))
// ->orderBy("created_at")
// ->groupBy(DB::raw("year(created_at)"))
// ->get()->toArray();
// $missing = array_column($missing, 'count');
// $noAnswer = DiraChatLog::select(DB::raw("SUM(numberofclick) as count"))
// ->orderBy("created_at")
// ->groupBy(DB::raw("year(created_at)"))
// ->get()->toArray();
// $noAnswer = array_column($noAnswer, 'count');
from Laravel Questions and Answers https://laravelquestions.com/php/convert-my-db-raw-to-laravel-eloquent-model/
via Lzo Media
No comments:
Post a Comment