コード例 #1
0
 /**
  * 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');
 }
コード例 #2
0
ファイル: CountryController.php プロジェクト: jnaxo/BankCodes
 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]);
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
ファイル: BankController.php プロジェクト: jnaxo/BankCodes
 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]);
 }
コード例 #5
0
 /**
  * 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);
 }
コード例 #6
0
ファイル: CountriesController.php プロジェクト: nirlewin/test
 /**
  * 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'));
 }
コード例 #7
0
 /**
  * Find a country by id.
  *
  * @param int $id
  * @return Country
  * @throws ModelNotFoundException
  */
 public function findById($id)
 {
     return Country::findOrFail($id);
 }
コード例 #8
0
 public function findCountry($countryId)
 {
     return Country::findOrFail($countryId);
 }
コード例 #9
0
 /**
  * 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);
 }
コード例 #10
0
 /**
  * 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');
 }
コード例 #11
0
 public function posts($id)
 {
     $country = Country::findOrFail($id);
     return view('country.posts', compact('country'));
 }