我正在laravel 5.2中进行项目,以便在" vehicleDetail.blade.php"中创建报告。我需要提供一个下拉选项,因为我需要获取数据库中的车辆名称。从该列表中,如果我选择一个车辆,选择fromDate,toDate然后单击生成报告我应该能够从数据库(设备表)中获取数据。对于这个过滤器引擎,如何从数据库中获取数据的下拉列表?
vehicleDetail.blade.php
@extends('app')
@section('content')
<br><br><br><br><br>
<div class="templatemo-content-wrapper">
<div class="container">
<ol class="breadcrumb">
<li><a href="{{ url("/") }}"><font color="green">Home</font></a></li>
<li class="active">Vehicle Detail</li>
</ol>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-success">
<div class="panel-heading">Vehicle Detail</div>
<div class="panel-body">
@if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.<br><br>
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form class="form-horizontal" role="form" method="POST" action="{{ url('group/update/') }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<label class="col-md-4 control-label">Vehicle</label>
<div class="col-md-6">
<input type="text" class="form-control" name="groupID" value="{{ ('#')}}">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">From Date</label>
<div class="col-md-6">
<input type="date" class="form-control" name="Fdate">
</div>
<label class="col-md-4 control-label">To Date</label>
<div class="col-md-6">
<input type="date" class="form-control" name="Tdate" >
</div>
</div>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" class="btn btn-warning">
Get Report
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
任何人请帮助我这样做,回应很明显。
答案 0 :(得分:0)
在您的控制器中,从变量中获取数据库中的所有值,如:
$list = DB::table('tablename')->get(array('id', 'name'));
并在视图上传递它:
return view('viewname', array('list' => $list));
现在在视图上使用它:
foreach($list as $key => $val)
{
//drop down html here
}