I want to make a dynamic chart for selected survey with id , where the answer's display in a chart and count how much this option selected .
I tried to use chart = Sondage::database(...) but i got Call to undefined method App\Charts\sondage::database()
Answer model :
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Answer extends Model
{
protected $fillable = ['answer','commentaire','user_id','survey_id','last_ip'];
protected $table = 'answer';
public function survey() {
return $this->belongsTo('App\Survey', 'survey_id');
}
public function question() {
return $this->belongsTo(Question::class);
}
public function user() {
return $this->belongsTo('App\User', 'user_id');
}
}
controller :
$chart = sondage::database(Answer::where('survey_id','=',$survey->id),'line','highcharts')
->title('Tokens')
->ElementLabel('Coins Sold')
->Responsive(true)
->dimensions(1000,500)
->data(Graph::find(1));
Could you help me to find a way to make that ?