当前位置: 首页>>代码示例>>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;未经允许,请勿转载。