public function index()
{
$lesson= DB::table('lessons')
->select('long_text')
->join('courses', 'courses.lesson_id', '=', 'lessons.id')
->where('courses.title', $courses)
->get();
return view(lesson.index);
}
在我的刀片中
<ul>
<li style="text-transform: uppercase;"> {{$courses->title}} </li>
</ul>
点击标题后,它应该显示该课程的课程
答案 0 :(得分:0)
您必须将数据返回到刀片:
public function index()
{
$course= DB::table('lessons')
->select('long_text')
->join('courses', 'courses.lesson_id', '=', 'lessons.id')
->where('courses.title', $courses)
->get();
return view(lesson.index, compact('course'));
}
然后,您可以使用以下代码段显示课程标题的内容
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Course title
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
All the details that you need to display of that course.
</div>
</div>
</div>
</div>
&#13;