Laravel 5 laravel 5.2中未定义foreach变量
我是laravel的新手,希望使用foreach填充我的视图。 这是一种观点:Laravel 5 laravel 5.2中未定义foreach变量,laravel-5,laravel-5.2,Laravel 5,Laravel 5.2,我是laravel的新手,希望使用foreach填充我的视图。 这是一种观点: <thead> <tr> <th>Sr. No.</th> <th>Name</th>
<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 }?>
路线:
Route::controller('vendor','VendorController');
我很长时间都在尝试,但还没有完成。非常感谢您的帮助。请提前感谢使用
compact()
以版本为基础传递数据。在这里阅读文档会有一些变化
注意:您尝试在
laravel
中应用codigniter
数据发送格式时语法错误尝试此操作您尝试在laravelcant中应用codigniter数据发送格式我们不知道我们喜欢这样做。laravel有点不同。数据应该像我下面提到的那样传递。谢谢@JYoThI。我将使用laravel中的foreach语法来尝试这个
Route::controller('vendor','VendorController');
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'));
}
}