/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(CityRequest $request, $id) { // $city = City::findOrFail($id); $city->update($request->all()); return redirect('addr/citys'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $this->validate($request, ['name' => 'required']); $item = City::findOrFail($id); $item->update($request->all()); Flash::success("Запись - {$id} обновлена"); return redirect(route('admin.cities.index')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($country_id, $city_id) { $statusCode = 200; $city = City::with(['country'])->findOrFail($city_id); if ($city->country->id != $country_id) { throw new ModelNotFoundException(); } $languages = City::findOrFail($city_id)->language()->get(); foreach ($languages as $language) { $response['languages'][] = ['id' => $language->id, 'language' => $language->language]; } return response($response, $statusCode); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $city = City::findOrFail($id); $city->delete(); return redirect('city'); }
/** * Remove the specified resource from storage. * * @param int $id * * @return \Illuminate\Http\Response */ public function destroy($id) { $city = City::findOrFail($id); $city->language()->detach([$id]); $city->delete(); $statusCode = 200; $response = ["success" => "City {$id} successfully destroyed"]; return response($response, $statusCode); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['file' => 'required', 'city' => 'required', 'year' => 'required']); $city = City::findOrFail($request->city); $tags = Keyword::get(); $parser = new SheetHandler($request->file); if (empty($request->month)) { $investiments = $parser->extractInvestimentsEachMonth(); foreach ($investiments as $investimentIdx => $investiment) { foreach ($investiment as $month => $singleMonth) { if (!empty($singleMonth->domain)) { $flag = 1; $singleMonth->city()->associate($city); $singleMonth->made_at = $request->year . '-' . sprintf("%02s", $month) . '-' . 1; foreach ($tags as $tag) { if (strpos(mb_strtolower($singleMonth, 'UTF-8'), $tag->name) !== FALSE) { $flag = 0; $singleMonth->category()->associate(Category::findOrFail($tag->category_id)); break; } } if ($flag) { $singleMonth->category()->associate(Category::where('name', 'Outros')->firstOrFail()); } } else { unset($investiments[$investimentIdx]); } } } foreach ($investiments as $investiment) { foreach ($investiment as $singleMonth) { $singleMonth->save(); } } } else { $investiments = $parser->extractInvestiments(); foreach ($investiments as $investimentIdx => $investiment) { if (!empty($investiment->domain)) { $flag = 1; $investiment->city()->associate($city); $investiment->made_at = $request->year . '-' . sprintf("%02s", $request->month) . '-' . 1; foreach ($tags as $tag) { if (strpos(mb_strtolower($investiment, 'UTF-8'), $tag->name) !== FALSE) { $flag = 0; $investiment->category()->associate(Category::findOrFail($tag->category_id)); break; } } if ($flag) { $investiment->category()->associate(Category::where('name', 'Outros')->firstOrFail()); } } else { unset($investiments[$investimentIdx]); } } foreach ($investiments as $invesitment) { $investiment->save(); } } return Redirect::route('admin.investimentos.index'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $city = City::findOrFail($id); $request->name = ucfirst(strtolower($request->name)); $this->validate($request, ['name' => 'required||max:255', 'population' => 'required|numeric', 'founded' => 'required']); $year = substr($request->founded, 6); $month = substr($request->founded, 3, -5); $day = substr($request->founded, 0, -8); $city->name = $request->name; $city->population = $request->population; $city->founded = $year . "-" . $month . "-" . $day; $city->save(); return Redirect::route('admin.cidades.index'); }
/** * Get a city by id. * * @param integer $id * @return boolean */ public function getById($id) { return City::findOrFail($id); }
/** * @param $all * @return array */ private function handleCityAnalytics($all) { $subcomponent = $all['subcomponents']; $city = City::findOrFail($all['cities']); $zones = $city->zone; $repairshops = collect(); foreach ($zones as $zone) { $shops = $zone->repairshop; $repairshops = $repairshops->merge($shops); } return $this->returnAnalysis($repairshops, $subcomponent, 'city', $city); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { $city = City::findOrFail($id); $city->update(['name' => $request->name]); return redirect('/admin/city'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $city = City::findOrFail($id); $city->delete(); return redirect()->route('settings.city.index'); }