/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Unit $unit) { if ($unit->delete()) { Flash::success('删除成功!'); return Redirect::to('admin/unit'); } else { Flash::error('删除失败!'); return Redirect::to('admin/unit'); } }
public function delete($id) { try { UnitModel::find($id)->delete(); $alert['msg'] = 'This square unit has been deleted successfully'; $alert['type'] = 'success'; } catch (\Exception $ex) { $alert['msg'] = 'This square unit focus has been already used'; $alert['type'] = 'danger'; } return Redirect::route('admin.square')->with('alert', $alert); }
/** * Get paths behind 'admin'. * * Compose sidebar variable. */ private function composeUnits() { View::composer('product.form', function ($view) { $view->with(['units' => Unit::all()->lists('name', 'id')]); }); }
public function editZones() { if (Request::ajax()) { $projectZoneId = Input::get('id'); $projectZone = ProjectZoneModel::find($projectZoneId); $projectType = ProjectTypeModel::whereRaw(true)->orderBy('type', 'asc')->get(); $unit = UnitModel::whereRaw(true)->orderBy('unit', 'asc')->get(); $velocityUnit = VelocityUnitModel::whereRaw(true)->orderBy('unit', 'asc')->get(); $tempUnit = TempUnitModel::whereRaw(true)->orderBy('unit', 'asc')->get(); $list = ''; $list .= '<div class="row"> <div class="col-md-12"> <form action ="' . URL::route('user.project.editZonesStore') . '" method="post" id="editZoneDiv">'; $list .= Form::token(); $list .= '<input type="hidden" name="zoneId" value="' . $projectZoneId . '"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <label>Select Type</label> <select name="projectType" class="form-control" id="projectType"> <option value="">Select Type</option>'; foreach ($projectType as $key => $value) { if ($value->id == $projectZone->projectZoneTypeId) { $list .= '<option value="' . $value->id . '" selected>' . $value->type . '</option>'; } else { $list .= '<option value="' . $value->id . '">' . $value->type . '</option>'; } } $list .= '</select> </div> </div> </div> <div class="row"> <div class="col-md-2"> <div class="form-group"> <label>W</label> <input type="text" name="w" class="form-control" id="w" value="' . $projectZone->areaWidth . '"> </div> </div> <div class="col-md-2"> <div class="form-group"> <label>L</label> <input type="text" name="l" class="form-control" id="l" value="' . $projectZone->areaLength . '"> </div> </div> <div class="col-md-2"> <div class="form-group"> <label>H</label> <input type="text" name="h" class="form-control" id="h" value="' . $projectZone->areaHeight . '"> </div> </div> <div class="col-md-3"> <div class="form-group"> <label>Unit</label> <select name="unit" class="form-control" id="unit"> <option value="">Unit</option>'; foreach ($unit as $key => $value) { if ($value->id == $projectZone->AreaUnitId) { $list .= '<option value="' . $value->id . '" selected>' . $value->unit . '</option>'; } else { $list .= '<option value="' . $value->id . '">' . $value->unit . '</option>'; } } $list .= ' </select> </div> </div> <div class="col-md-3"> <div class="form-group"> <label>Sq</label> <input type="text" name="sq" class="form-control" id="sq" value="' . $projectZone->areaSquareFoot . '"> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label>Fresh Air Velocity</label> <input type="text" class="form-control" name="airVelocity" placeholder="Fresh Air Velocity" id="airVelocity" value="' . $projectZone->freshAirVelocity . '"> </div> </div> <div class="col-md-2"> <div class="form-group"> <label>Unit</label> <select class="form-control" name="airVelocityUnit" id="airVelocityUnit"> <option value="">Unit</option>'; foreach ($velocityUnit as $key => $value) { if ($value->id == $projectZone->freshAirVelocityUnitId) { $list .= '<option value="' . $value->id . '" selected>' . $value->unit . '</option>'; } else { $list .= '<option value="' . $value->id . '">' . $value->unit . '</option>'; } } $list .= ' </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>Exhaust Air Velocity</label> <input type="text" class="form-control" name="exhaustVelocity" placeholder="Exhaust Air Velocity" id="exhaustVelocity" value="' . $projectZone->exhastAirVelocity . '"> </div> </div> <div class="col-md-2"> <div class="form-group"> <label>Unit</label> <select class="form-control" name="exhaustVelocityUnit" id="exhaustVelocityUnit"> <option value="">Unit</option>'; foreach ($velocityUnit as $key => $value) { if ($value->id == $projectZone->exhastAirVelocityUnitId) { $list .= '<option value="' . $value->id . '" selected>' . $value->unit . '</option>'; } else { $list .= '<option value="' . $value->id . '">' . $value->unit . '</option>'; } } $list .= ' </select> </div> </div> </div> <!-- Third line--> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label>Fresh Air %</label> <input type="text" name="freshAir" class="form-control" placeholder="Fresh Air %" id="freshAir" value="' . $projectZone->freshAir . '"> </div> </div> <div class="col-md-2"> <div class="form-group"> <label>W</label> <input type="text" name="ductW" class="form-control" placeholder="Duct Width" id="ductW" value="' . $projectZone->ductWidth . '"> </div> </div> <div class="col-md-2"> <div class="form-group"> <label>H</label> <input type="text" name="ductH" class="form-control" placeholder="Duct Height" id="ductH" value="' . $projectZone->ductHeight . '"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>Duct Air Velocity</label> <input type="text" name="ductAirVelocity" class="form-control" placeholder="Duct Height" id="ductAirVelocity" value="' . $projectZone->ductAirVelocity . '"> </div> </div> </div> <!-- third line --> <div class="row "> <div class="col-md-4"> <div class="form-group"> <label>Outdoor Temp</label> <input type="text" name="outDoorTemp" class="form-control" placeholder="Outdoor Temp" id="outDoorTemp" value="' . $projectZone->OutdoorTemp . '"> </div> </div> <div class="col-md-2"> <label>Unit</label> <select name="outTempUnit" class="form-control" id="outTempUnit"> <option>Unit</option>'; foreach ($tempUnit as $key => $value) { if ($value->id == $projectZone->OutdoorTempUnitId) { $list .= '<option value="' . $value->id . '" selected>' . $value->unit . '</option>'; } else { $list .= '<option value="' . $value->id . '">' . $value->unit . '</option>'; } } $list .= '</select> </div> <div class="col-md-4"> <div class="form-group"> <label>Target Temp</label> <input type="text" name="targetTemp" class="form-control" placeholder="Target Temp" id="targetTemp" value="' . $projectZone->TargetTemp . '"> </div> </div> <div class="col-md-2"> <label>Unit</label> <select name="targetTempUnit" class="form-control" id="targetTempUnit"> <option>Unit</option>'; foreach ($tempUnit as $key => $value) { if ($value->id == $projectZone->TargetTempUnitId) { $list .= '<option value="' . $value->id . '" selected>' . $value->unit . '</option>'; } else { $list .= '<option value="' . $value->id . '">' . $value->unit . '</option>'; } } $list .= '</select> </div> </div> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label>Custom Field</label> <input type="text" class="form-control" name="custom" placeholder="Custom Field" id="custom" value="' . $projectZone->custom . '"> </div> </div> </div> <div class="row margin-bottom-20"> <div class="col-md-12"> <div class="form-group"> <label >Notes</label> <textarea class="form-control" name="notes" placeholder="Notes" rows="5" id="notes">' . $projectZone->note . '</textarea> </div> </div> </div> <div class="row"> <div class="col-md-12 text-right"> <input type="button" class="btn-u btn-u-blue" onclick="onEditZoneStore()" value="Edit Zone"> <button type="button" class="btn-u btn-u-red" data-dismiss="modal">Cancel</button> </div> </div> </form> </div> </div>'; return Response::json(['result' => 'success', 'list' => $list]); } }