public function getReq($city) { $areas = Areas::where('city', $city)->get(); $data = []; $i = 0; foreach ($areas as $area) { $requirementsPerArea = Requirements::where('areaCode', $area->id)->get(); foreach ($requirementsPerArea as $req) { $data[$i]['areaName'] = $area->area; $data[$i]['requirements'] = $req->requirement; $volunteer = Volunteers::where('id', $req->volunteerId)->first(); $data[$i]['name'] = $volunteer->username; $data[$i]['contact'] = $volunteer->contact; $i++; } } return view('user.city')->with('data', $data); }
public function editArea(request $request) { $validator = Validator::make($request->all(), ['title' => 'required', 'area_id' => 'required', 'city_id' => 'required']); $input = $request->only('area_id', 'title', 'city_id'); if ($validator->fails()) { return redirect('admin/element/area/' . $input['area_id'] . '/edit')->withErrors($validator); } $element = Areas::where('id', $input['area_id'])->first(); $element->title = $input['title']; $element->city_id = $input['city_id']; $element->save(); return redirect('admin/elements'); }