我是laravel的新手,想要使用foreach来填充我的视图。 这是观点:
<thead>
<tr>
<th>Sr. No.</th>
<th>Name</th>
<th>Mobile No</th>
<th>Email ID</th>
<th>Address</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach($result as $res){?>
<tr>
<td>1</td>
<td><?php echo $res->vendor_name;?></td>
<td><?php echo $res->mobile;?></td>
<td><?php echo $res->email;?></td>
<td><?php echo $res->city;?></td>
<td>
<a href="#" data-toggle="modal" data-target=".Upcoming" class="btn btn-success btn-sm"><i class="fa fa-edit"></i></a>
<a href="#" class="btn btn-warning btn-sm"><i class="fa fa-trash"></i></a>
</td>
</tr>
<?php }?>
控制器:
class VendorController extends Controller
{
public function getVendorList(){
$vendors=DB::table('vendor_master')->get();
$data['result']=$vendors;
$data['header'] = View::make('header')->render();
$data['footer'] = View::make('footer')->render();
return view('vendor_details', $data);
}
}
路线:
Route::controller('vendor','VendorController');
我正在尝试很长一段时间但没有通过。我会很感激liitle的帮助。谢谢提前
答案 0 :(得分:1)
数据应该使用基于版本的class VendorController extends Controller
{
public function getVendorList(){
$vendors=DB::table('vendor_master')->get();
$result=$vendors;
$header = View::make('header')->render();
$footer = View::make('footer')->render();
return view('vendor_details',compact( 'result','header','footer'));
}
}
这样传递,它会稍微更改一下阅读文档laravel documenation
codigniter
注意:您尝试在laravel
mongoimport
数据发送格式