當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Country::findOrFail方法代碼示例

本文整理匯總了PHP中app\Country::findOrFail方法的典型用法代碼示例。如果您正苦於以下問題:PHP Country::findOrFail方法的具體用法?PHP Country::findOrFail怎麽用?PHP Country::findOrFail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Country的用法示例。


在下文中一共展示了Country::findOrFail方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(EditCountryRequest $request, $id)
 {
     $country = Country::findOrFail($id);
     $country->fill($request->all());
     $country->save();
     return redirect()->route('settings.country.index');
 }
開發者ID:raulbravo23,項目名稱:salepoint,代碼行數:13,代碼來源:CountrysController.php

示例2: show

 public function show($id)
 {
     $links[1] = 'active';
     try {
         $country = Country::findOrFail($id);
     } catch (ModelNotFoundException $ex) {
         return view('errors.404');
     }
     return view('country.show', ['country' => $country, 'links' => $links]);
 }
開發者ID:jnaxo,項目名稱:BankCodes,代碼行數:10,代碼來源:CountryController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($country_id)
 {
     $statusCode = 200;
     $response = ['cities' => []];
     Country::findOrFail($country_id);
     $cities = City::with('country')->where('country_id', '=', $country_id)->get();
     foreach ($cities as $city) {
         $response['cities'][] = ['id' => $city->id, 'city' => $city->city, 'country_id' => $country_id, 'country' => $city->country->country];
     }
     return response($response, $statusCode);
 }
開發者ID:mudragel,項目名稱:matematika-test.loc,代碼行數:16,代碼來源:CityController.php

示例4: show

 public function show($alpha2, $id)
 {
     $links[1] = 'active';
     try {
         $bank = Bank::findOrFail($id);
         $country = Country::findOrFail($alpha2);
     } catch (ModelNotFoundException $ex) {
         return view('errors.404');
     }
     return view('bank.show', ['bank' => $bank, 'country' => $country, 'links' => $links]);
 }
開發者ID:jnaxo,項目名稱:BankCodes,代碼行數:11,代碼來源:BankController.php

示例5: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $country = Country::findOrFail($id);
     $country->delete();
     $statusCode = 200;
     $response = ["success" => "Country {$id} successfully destroyed"];
     return response($response, $statusCode);
 }
開發者ID:mudragel,項目名稱:matematika-test.loc,代碼行數:15,代碼來源:CountryController.php

示例6: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     //$this->validate($request, ['name' => 'required']); // Uncomment and modify if needed.
     $country = Country::findOrFail($id);
     $update = $request->all();
     // is new image uploaded?
     if ($file = Input::file('image')) {
         $fileName = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension() ?: 'png';
         $folderName = '/uploads/';
         $destinationPath = Config::get('app.path') . $folderName;
         $safeName = time() . "_" . str_random(10) . '.' . $extension;
         $file->move($destinationPath, $safeName);
         //delete old pic if exists
         if (File::exists(Config::get('app.path') . $country->image)) {
             File::delete(Config::get('app.path') . $country->image);
         }
         $update['image'] = $safeName ? $folderName . $safeName : '';
     }
     if (isset(Country::$boolean)) {
         foreach (Country::$boolean as $field) {
             if (isset($update[$field]) && $update[$field] == "on") {
                 $update[$field] = 1;
             } else {
                 $update[$field] = 0;
             }
         }
     }
     $country->update($update);
     return redirect('admin/countries')->with('success', Lang::get('message.success.update'));
 }
開發者ID:nirlewin,項目名稱:test,代碼行數:37,代碼來源:CountriesController.php

示例7: findById

 /**
  * Find a country by id.
  *
  * @param int $id
  * @return Country
  * @throws ModelNotFoundException
  */
 public function findById($id)
 {
     return Country::findOrFail($id);
 }
開發者ID:manishkiozen,項目名稱:Cms,代碼行數:11,代碼來源:CountryRepository.php

示例8: findCountry

 public function findCountry($countryId)
 {
     return Country::findOrFail($countryId);
 }
開發者ID:skiwei,項目名稱:sayangholidays,代碼行數:4,代碼來源:CountryRepository.php

示例9: getCountryDetails

 /**
  * Get the Detail Info about individual country
  */
 public function getCountryDetails($id, $name)
 {
     $sortableColumns = ['position', 'rank_id', 'name', 'player_rating', 'total_score', 'total_points', 'total_time_played', 'last_game_id'];
     $orderBy = Request::has('orderBy') && in_array(Request::get('orderBy'), $sortableColumns) ? Request::get('orderBy') : 'position';
     $sortDir = Request::has('direction') ? Request::get('direction') : 'asc';
     //$players = PlayerTotal::orderBy($orderBy,$sortDir)->paginate(10);
     $country = Country::findOrFail($id);
     $players = $country->playerTotals()->orderBy($orderBy, $sortDir)->with('country', 'rank', 'lastGame')->paginate(35);
     $array = ['players' => $players, 'countryName' => $country->countryName, 'countryId' => $country->id];
     return view('statistics.country-players', $array);
 }
開發者ID:kinnngg,項目名稱:knightofsorrow,代碼行數:14,代碼來源:StatisticsController.php

示例10: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $country = Country::findOrFail($id);
     $country->delete();
     return redirect('country');
 }
開發者ID:jeanyu,項目名稱:azredirentals,代碼行數:12,代碼來源:CountryController.php

示例11: posts

 public function posts($id)
 {
     $country = Country::findOrFail($id);
     return view('country.posts', compact('country'));
 }
開發者ID:smronju,項目名稱:Laravel-Eloquent-Relationships,代碼行數:5,代碼來源:CountryController.php


注:本文中的app\Country::findOrFail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。