本文整理汇总了PHP中app\City::findOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP City::findOrFail方法的具体用法?PHP City::findOrFail怎么用?PHP City::findOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\City
的用法示例。
在下文中一共展示了City::findOrFail方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* 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');
}
示例2: update
/**
* 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'));
}
示例3: 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);
}
示例4: destroy
/**
* 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');
}
示例5: destroy
/**
* 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);
}
示例6: store
/**
* 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');
}
示例7: update
/**
* 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');
}
示例8: getById
/**
* Get a city by id.
*
* @param integer $id
* @return boolean
*/
public function getById($id)
{
return City::findOrFail($id);
}
示例9: handleCityAnalytics
/**
* @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);
}
示例10: update
/**
* 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');
}
示例11: destroy
/**
* 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');
}