Ejemplo n.º 1
0
 /**
  * POST /api/$version/mod-edit/$id.
  *
  * @api
  *
  * @return json
  */
 public function postModEdit($id)
 {
     $user = $this->user();
     if ($user) {
         $comment = Input::get('comment', false);
         if ($comment) {
             try {
                 $mod = Mod::findOrFail($id);
             } catch (Exception $e) {
                 return $this->error('missing', 'beatmaps.modding');
             }
             if ($user->canEditMod($mod)) {
                 // you can edit
                 $mod->comment = $comment;
                 $mod->edit_count += 1;
                 $mod->save();
                 return Response::json(['success' => $mod->toArray()]);
             }
         } else {
             return $this->error('comment', 'beatmaps.modding');
         }
     }
     return $this->error('access-denied', 'beatmaps.modding');
 }