php - laravel4-send more than one array from controller to view -
i have created small applications , creating edit form. have 2 tables 1 "cars" , other named "classes". table clrs has field named class has id of table classes. have join query gets data 2 tables , displays @ form. problem want create dropdown list @ field "class" gets classes table classes , displays dropdown, want set default value class id in table "cars".
public function edit($id) { $values = db::table('cars') ->join('classes', 'cars.class', '=', 'classes.id') ->select('cars.*', 'classes.class') ->where ('cars.id','=',$id) ->get(); return view::make('pages.edit')->with('values', $values); }
edit.blade.php
<div class="form-group"> {{ form::label('class', 'class', array('class'=>'control-label col-lg-4')) }} <div class="col-lg-8"> {{ form::text('class', $v->class, array('class' => 'form-control')) }} </div> </div>
i want create other query @ controller gets classes existing in table classes , put them @ form dropdown list. don't know how pass 2 arrays @ view. need help
just pass array, it's way easier:
public function edit($id) { $data['values'] = db::table('cars') ->join('classes', 'cars.class', '=', 'classes.id') ->select('cars.*', 'classes.class') ->where ('cars.id','=',$id) ->get(); $data['otherarray'] = ['other', 'elements']; $data['anothervar'] = 'this string'; return view::make('pages.edit', $data); }
in view you'll have $values
, $otherarray
, $anothervar
, on.
Comments
Post a Comment