当前位置: 首页>>代码示例>>PHP>>正文


PHP City::findOrFail方法代码示例

本文整理汇总了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');
 }
开发者ID:seahouse,项目名称:hxerp,代码行数:14,代码来源:CitysController.php

示例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'));
 }
开发者ID:jambik,项目名称:sellmecar,代码行数:15,代码来源:CitiesController.php

示例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);
 }
开发者ID:mudragel,项目名称:matematika-test.loc,代码行数:18,代码来源:LanguageController.php

示例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');
 }
开发者ID:jeanyu,项目名称:azredirentals,代码行数:12,代码来源:CityController.php

示例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);
 }
开发者ID:mudragel,项目名称:matematika-test.loc,代码行数:16,代码来源:CityController.php

示例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');
 }
开发者ID:EnriqueSampaio,项目名称:dag-parser,代码行数:67,代码来源:InvestimentController.php

示例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');
 }
开发者ID:EnriqueSampaio,项目名称:dag-parser,代码行数:21,代码来源:CityController.php

示例8: getById

 /**
  * Get a city by id.
  *
  * @param  integer $id
  * @return boolean
  */
 public function getById($id)
 {
     return City::findOrFail($id);
 }
开发者ID:purgesoftwares,项目名称:bloodapp,代码行数:10,代码来源:CityRepository.php

示例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);
 }
开发者ID:Korogba,项目名称:inventory,代码行数:16,代码来源:HomeController.php

示例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');
 }
开发者ID:francoislevesque,项目名称:lavalpme,代码行数:13,代码来源:cityController.php

示例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');
 }
开发者ID:raulbravo23,项目名称:salepoint,代码行数:12,代码来源:CitysController.php


注:本文中的app\City::findOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。