php - Laravel Controller to View using chart -


looking help. i'm new laravel , stack overflow please gentle. basically, i'm trying data controller match current question id. have 4 tables, survey, user, questions, answers.

i'm trying dynamically render chart each questions answers on view page. can work "all" answers, can't seem work answer unless hard code question id. appreciated.

controller

public function view_survey_answers(survey $survey, charts $chart, answer $answer, question $question)   $survey = $survey->load('user.questions.answers');    $chart = charts::database($answer->load('survey.question')->get(), 'bar', 'material')     ->title("answers user")     ->elementlabel("total")     ->responsive(0)     ->groupby('answers->answer')     ->labels(['static']);   return view('answer.view', compact('survey', 'chart')); 

model

<?php  namespace app;  use illuminate\database\eloquent\model;  class answer extends model { protected $fillable = [     'answer' ];  protected $table = 'answers';  public function survey(){     return $this->belongsto(survey::class); }  public function question(){     return $this->belongsto(question::class); } 

again, appreciated. i'm sure in eloquent i'm missing.

-m


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -