lundi 22 août 2016

sql count function returning object as output in laravel

I'm passing value from laravel model to blade, am getting [object Object] as output. I want number or array.

Model:

public static function count($data){
  $post_id = $data->a;  
  $count_value=DB::select('select count(*) as count FROM pp_like WHERE  post_id= ?', [$post_id]); 
  return (array)$count_value[0];
}

blade-js:

res.success(function(data, status, headers, config) {
  alert(data);
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire