通过模型关系查看条件时如何使用。拉拉韦尔

时间:2018-06-22 02:14:08

标签: laravel eloquent

我只想通过{{ choice_question_number }}where('user_id',Auth::id());

  

查看如何检查user_id或如何使用user_id检入控制器。我正在使用问题模型(即问题模型)来提问。

查看

@foreach ($duplicate->topic->choices as $choice)
    {{ $choice->question_number }}
@endforeach

控制器

$duplicates = Question::selectRaw("count('id') as total, topic_id")->with('topic', 'topic.choices')->groupBy('topic_id')->get();
return view('choices.index',compact('too','duplicates'));

模型

protected $fillable = [
    'user_id',
    'time',
    'topic_id',
    'question_number'
];

public function topic(){
    return $this->belongsTo('App\Topic');
}

0 个答案:

没有答案
相关问题