示例#1
0
 /**
  * 
  * Remove the project alongside deploy dir.
  * @param type $id
  * @return type
  */
 public function get_delete($id)
 {
     $project = Projects::find($id);
     $m = new Messages();
     if (!$project) {
         $m->add('error', "Unknown project!");
         return Redirect::to(handles('orchestra::resources/githubdeploys'))->with('message', $m->serialize());
     }
     $proj = new Githubdeploys\Release();
     $proj->deleteProject($project);
     if ($project->delete()) {
         Deploys::where('project_id', '=', $id)->delete();
         $m->add('success', "Project deleted alongside deploy path!");
     } else {
         $m->add('error', "Could not remove project from the database!");
     }
     return Redirect::to(handles('orchestra::resources/githubdeploys'))->with('message', $m->serialize());
 }
示例#2
0
 /**
  * 
  * Delete release.
  * @param type $id
  * @return type
  */
 public function get_delete($id = null)
 {
     $release = new Deploys();
     $release = $release->findWithProject($id);
     if (!$release) {
         $m = new Messages();
         $m->add('error', "Unknown release!");
         return Redirect::to(handles('orchestra::resources/githubdeploys'))->with('message', $m->serialize());
     }
     $project = (object) $release[0]->relationships['projects'];
     $release = (object) $release[0]->attributes;
     $rel = new \Githubdeploys\Release();
     $response = $rel->deleteRelease($project, $release);
     $m = new Messages();
     if (isset($response['error'])) {
         foreach ($response['error'] as $r) {
             $m->add('error', $r);
         }
     } else {
         foreach ($response['success'] as $r) {
             $m->add('success', $r);
         }
         /*
          * We have to reinitialise $release because it's not an instance
          * of the model \Githubdeploys\Deploys anymore. Read above the code^
          */
         if (Deploys::find($release->id)->delete()) {
             $m->add('success', sprintf("Release %i (%s) has been deleted from the database.", $release->id, $release->release));
         } else {
             $m->add('error', sprintf("Could not delete release %i from the database.", $release->id));
         }
     }
     return Redirect::to(Request::referrer())->with('message', $m->serialize());
 }