예제 #1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     //
     $community = Community::with('subdistrict')->find($id);
     $subdistricts = SubDistrict::lists('subdistrict', 'subdistrict_id');
     if (is_null($community)) {
         Session::flash('message', 'Community could not be found!');
         Session::flash('alert-class', 'alert-warning');
         return Redirect::route('community.index');
     }
     return View::make('communities.edit', compact('community', 'subdistricts'));
 }
 public function getSubDistricts()
 {
     //
     $district = Input::get('district');
     if (!$district) {
         return false;
     }
     $options = "";
     $lists = SubDistrict::whereRaw('district_id = ? ', array($district))->get();
     foreach ($lists as $k => $v) {
         $id = $v->id;
         $data = $v->name;
         $options .= '<option value="' . $id . '">' . $data . '</option>';
     }
     return $options;
 }