public function select_printer() { try { Log::info('======> Test Printer <======'); $type_printer = Input::get('type_printer'); //$printers = PrinterParents::where('parentId',$type_printer)->printer_alias()->printers()->get(); if ($type_printer == 'all') { $printers = ''; } else { $printer_parents = PrinterParents::where('parentId', $type_printer)->first(); $printers = $printer_parents->printer_alias()->get(); } //return Response::json(['status' => 'success', 'msg' => 'test']); return View::make('qlmadministrator.printers')->with(array('printers' => $printers, 'selected' => $type_printer)); } catch (Exception $_ex) { Session::flash('error', '$$$ --- Error (' . $_ex->getMessage() . ') --- $$$'); Log::error('$printers:' . $_ex->getMessage()); return View::make('qlmadministrator.printers')->with(array('printers' => $printers, 'selected' => $type_printer)); } }
<span class="pull-left"><i class="fa fa-plus"></i> Add New Product</span> <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span> <div class="clearfix"></div> </div> </a> </div> </div> </div> <!-- /.row --> <div class="row"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"> <h2>List of Products</h2> <div class="form-group"> <label>Product Brand</label> <?php $types = PrinterParents::where('parentType', '1')->get(); ?> <form action="{{asset('qlm-admin/select-printer')}}" method="POST"> <div class="row"> <div class="col-md-8"> <select class="form-control" name="type_printer" id="type_printer"> <option value="all" @if(isset($selected) && $selected=='all') {{'selected'}} @endif>All</option> @foreach($types as $type) <option value="{{$type->parentId}}" @if(isset($selected) && $selected==$type->parentId) {{'selected'}} @endif>{{$type->parentName}}</option> @endforeach </select> </div> <div class="col-md-4"> <button type="submit" class="btn btn-default btn-primary">Search</button> </div> </div>