我正在显示数据库中的摘要,我想使用下拉菜单过滤它们。
我已经创建了下拉菜单,其中的类别是医学和护理
包含下拉菜单的我的视图
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-
toggle="dropdown" value="">Show all</button>
<ul class="dropdown-menu" role="menu">
@foreach ($schools as $school)
<li value="{{ $school->id }}"><a href="{{$school->School_ID}}">{{ $school->School_Type }}</a></li>
@endforeach
</ul>
</div>
我的控制器
public function index(Request $request)
{
$schools = School::all();
$items = $request->items ?? 5; // get the pagination number or a default
$abstracts = Project::orderBy('A_ID','asc')->paginate($items);
return view ('Abstracts.index')->with ('abstracts', $abstracts)
->withItems($items)
->with('schools',$schools);
}
有人可以指导如何正确路由
答案 0 :(得分:0)
我会这样:
public function index(Request $request)
{
$schools = School::all();
$items = $request->items ?? 5; // get the pagination number or a default
$abstracts = Project::orderBy('A_ID','asc')->paginate($items);
return view ('Abstracts.index')->with([
'abstracts' => $abstracts,
'items' => $items,
'schools' => $schools
]);
}
在您看来,您可以像这样确认它:
@foreach ($schools as $school)
{{ $school }}
@endforeach