public function show($slug) { //DB::table('yourtablename')->where('yourcolumn','value')->groupBy('column','column')->get(); $result = result::select(DB::raw('vote,slug, count(*) as count'))->where('slug', '=', $slug)->groupBy('vote', 'slug')->get(); $question = question::whereSlug($slug)->firstOrFail(); //result::whereSlug($slug)->whereVote('option1')->first()->count('*'); //result::all(); //where('slug','=',$slug)->groupBy('vote')->first()->count(); //result::whereSlug($slug)->whereVote('option1')->count()->first(); //DB::table('results')->select(DB::raw('count(*) as count')) // ->where('slug', '=', $slug) // ->groupBy('vote') // ->get(); //DB::table('results')->where('slug',$slug)->groupBy('vote','slug')->first(); //result::select(result::raw('select (vote, slug) count(*) as count where slug = ',$slug,' Group by vote, slug'))->first(); //select('vote','slug')->count('*')->where('slug','=',$slug)->groupBy('vote')->get(); //result::select('vote','slug')->count('*')->where('slug','=',$slug)->groupBy('vote')->get(); //result::whereSlug($slug)->whereVote('option1')->firstOrFail(); // select(result::raw('count("vote") as votes')) ->where('slug', $slug)->get(); //count('vote')->where('Slug',$slug)->whereVote('option1')->firstOrFail(); //SELECT vote, slug, COUNT(*) FROM results where slug = '56583a4852f37' Group by vote, slug return view('results.show', compact('result', 'question')); }