mardi 28 avril 2020

how i can count different different multiple same category according to date in laravel

This is my query i want to get sperate count of same category id

DB::table('form_categories')
        ->rightjoin('form_submissions','form_categories.id','=','form_submissions.category_id')
        ->where('form_submissions.user_id' , Auth::user()->id)
        ->where('form_submissions.created_at', '>', Carbon::now()->startOfWeek())
        ->where('form_submissions.created_at', '<', Carbon::now()->endOfWeek())
        ->groupBy('date')
        ->orderBy('date', 'DESC')
        ->get(array(
            DB::raw('Date(form_submissions.created_at) as date'),
            DB::raw('COUNT(form_submissions.category_id) as "category"'), 
        ));


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire