user7946345
user7946345

Reputation:

Use of undefined constant value - assumed 'value'

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

Answers (1)

Marcin Nabiałek
Marcin Nabiałek

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

Related Questions