You Statement Should be;
result = DB::table('yourtablename')->where('yourcolumn','value')->groupBy('column','column')->get();
return compact('result');
$users = DB::table('users')
->select(DB::raw('count(*) as user_count, status'))
->where('status', '<>', 1)
->groupBy('status')
->get();
Read about Laravel Query Builder
Thanks Jibran! but now it returns a message "Undefined property: stdClass::$result", I don't understand what it means.
and I run this query with eloquent model,
result::where('slug','=',$slug)->groupBy('vote')->first()->count();
but it return "Trying to get property of non-object"
and this is my view
@extends('master')
@section('title', 'View a question')
@section('content')
<div class="container col-md-8 col-md-offset-2">
<div class="well well bs-component">
@foreach($result as $result)
<tr>
<td>{!! $result->id !!} </td>
<td>{!! $result->vote !!}</td>
<td>{!! $result->slug !!}</td>
<td>{!! $result->count !!}</td>
</tr>
@endforeach
</div>
@endsection
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community