1、控制器
public function show($id) { $goods = Goods::select('goods.*')->where('goods.id', '=', $id)->get(); $data = []; foreach($goods as $key=>$v) { $data[$key]['id'] = $v->id; $data[$key]['name'] = $v->name; $data[$key]['product_code'] = $v->product_code; $data[$key]['class_name'] = $v->goodsclass->class_name; $data[$key]['nums'] = $v->goodsNexus->count(); $data[$key]['price'] = $v->price; $data[$key]['goods_info'] = $v->goods_info; $data[$key]['img'] = $v->img; $data[$key]['site'] = $v->site; $data[$key]['work_company'] = $v->work_company; $data[$key]['status'] = $v->status; $data[$key]['area'] = $v->area; $data[$key]['product_at'] = $v->product_at; $data[$key]['created_at'] = $v->created_at; $data[$key]['productdate'] = $v->productdate; } $datas=$data;
->with( 'datas', $datas[0]) //遍历到视图
2、view
<span>{{$datas['name']}}</span>
@if($datas['status']==1) <span style="color:red;">上架中</span> @else <span style="color: green;">已上架</span> @endif
3、js 注意:jquery,jquery-form.js layer插件的引入 bootstrap相关的引入
$("#addForm").ajaxSubmit({ url:"{{url('/admin/commodity/update/'.$datas['id'])}}" ,
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
长按识别二维码并关注微信
更方便到期提醒、手机管理