當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。