public function aprobare()
 {
     $id = Input::get('id');
     if (!($terrain = Terrain::find($id))) {
         throw new Exception('Nu gasim terenul cu id: ' . $id);
     }
     $terrain->aprobat = !$terrain->aprobat;
     $terrain->save();
     return $terrain;
 }
 /**
  * Affiche le formulaire pour éditer la ressource.
  *
  * @param  int  $id l'id du terrain à éditer 
  * @return Response
  */
 public function edit($id)
 {
     try {
         $terrain = Terrain::findOrFail($id);
         $regions = Region::all();
         $terrainSports = Terrain::find($id)->sports;
         $sports = Sport::all();
         return View::make('terrains.edit', compact('terrain', 'regions', 'sports', 'terrainSports'));
     } catch (Exception $e) {
         App::abort(404);
     }
 }
 public function open()
 {
     $id = Input::get('id');
     if ($id == false) {
         // return doar credit (pt reresh)
         return success(['credit' => auth()->user()->credit], 'Credit actualizat. Incercati sa deschideti contactul proprietarului din nou. Aveti:' . auth()->user()->credit . ' RON.');
     }
     if (auth()->user()->credit <= config('credit.pret_cumparator')) {
         return error('Nu aveti suficient credit', ['credit' => auth()->user()->credit]);
     } else {
         User::credit(-config('credit.pret_cumparator'));
         UnlokedTerrain::create(['user_id' => auth()->user()->id, 'terrain_id' => $id]);
         return success(['success' => 'Am deschis', 'credit' => auth()->user()->credit, 'telefon' => Terrain::find($id)->telefon]);
     }
 }