我正在尝试将值传递给引导程序模型,但是对于每个行,编辑按钮仅显示最后一行ID。如何在每一行上显示编辑按钮?
以下是我的代码示例:
@foreach($data as $cat_values)
<tr>
<td><input type="checkbox" class="checkthis" /></td>
<td>{{$cat_values->cat_name}}</td>
<td>{{$cat_values->cat_desc}}</td>
<td>{{$cat_values->cat_slug}}</td>
<td>{{$cat_values->created_at}}</td>
<td>{{$cat_values->updated_at}}</td>
<td><p data-id="{{$cat_values->id}}" data-placement="top" data-toggle="tooltip" title="Edit">
<button data-id="{{$cat_values->id}}" class="btn btn-primary btn-xs edit-page" data-title="Edit" data-toggle="modal" data-target="#edit" >
<span class="glyphicon glyphicon-pencil"></span></button></p></td>
<td><p data-id="{{$cat_values->id}}" data-placement="top" data-toggle="tooltip" title="Delete"><button class="btn btn-danger btn-xs edit-page" data-title="Delete" data-toggle="modal" data-target="#delete" ><span class="glyphicon glyphicon-trash"></span></button></p></td>
<td><p data-placement="top" data-toggle="tooltip" title="Delete"><button class="btn btn-danger btn-xs" data-title="Delete" data-toggle="modal" data-target="#delete" ><span class="glyphicon glyphicon-trash"></span></button></p></td>
</tr>
@endforeach;
以下是模型:
<div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-labelledby="edit" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>
<h4 class="modal-title custom_align" id="Heading">Edit Your Detail</h4>
</div>
<div class="modal-body">
<div class="form-group">
<input type="text" id="id" name="id" value="" />
<input class="form-control " type="text" placeholder="" value="{{$cat_values->cat_name}}">
</div>
<div class="form-group">
<input class="form-control " type="text" placeholder="" value="{{$cat_values->parent_cat}}">
</div>
<div class="form-group">
<textarea rows="2" class="form-control" placeholder="" value="">{{$cat_values->parent_cat}}</textarea>
</div>
<div class="form-group">
<input class="form-control " type="text" placeholder="" value="{{$cat_values->cat_desc}}">
</div>
<div class="form-group">
<input class="form-control " type="text" placeholder="" value="{{$cat_values->cat_slug}}">
</div>
</div>
<div class="modal-footer ">
<button type="button" class="btn btn-warning btn-lg" style="width: 100%;"><span class="glyphicon glyphicon-ok-sign"></span> Update</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
如何在Laravel中将值传递给bootstrap模型?谢谢。
更新
public function viewCategory()
{
$retrive=Category::all();
$data=['data'=>$retrive];
return view('a.view_category',$data);
}
并且如果我打印数据
@foreach($data as $value)
{{$value->id;}}
{{$value->cat_name}}
{{$value->cat_desc}}
{{$value->cat_slug}}
@endforeach