Reputation:
Use of undefined constant value - assumed 'value' how i access?
public function idcount($id)
{
$stats = DB::table('questions')
->select( DB::raw("COUNT('id') as value"))
->where('user_id',$id)
->groupBy('user_id')
->get(
);
return $stats.value;
}
Upvotes: 1
Views: 1885
Reputation: 111889
You should use:
return $stats[0]->value;
instead of
return $stats.value;
because you are using Query Builder and get
method returns collection of results and you want to get value
column from this collection
Upvotes: 2