示例#1
0
 /**
  * @return int
  */
 protected function showMounts()
 {
     $_mounts = Models\Mount::orderBy('mount_id_text')->get();
     if (empty($_mounts)) {
         $this->info('** No mounts found **');
         return 0;
     }
     foreach ($_mounts as $_mount) {
         $_used = 0 != Models\Server::where('mount_id', $_mount->id)->count();
         $this->writeln(($_used ? '*' : ' ') . '<info>' . $_mount->mount_id_text . "</info>\t" . '<comment>' . json_encode($_mount->config_text) . '</comment>');
     }
     return 0;
 }
示例#2
0
 /**
  * Determines if a mount is currently assigned to a server
  *
  * @param int $mountId
  *
  * @return bool
  */
 public function isInUse($mountId)
 {
     /** @noinspection PhpUndefinedMethodInspection */
     return Server::where('mount_id', $mountId)->count() > 0;
 }
 public function destroy($ids)
 {
     try {
         $id_array = [];
         $server_names = [];
         if ($ids == 'multi') {
             $params = Input::all();
             $selected = $params['_selected'];
             $id_array = explode(',', $selected);
         } else {
             $id_array = explode(',', $ids);
         }
         foreach ($id_array as $id) {
             $server = Server::where('id', '=', $id);
             $server_name = $server->get(['server_id_text']);
             array_push($server_names, '"' . $server_name[0]->server_id_text . '"');
             $server->delete();
             ClusterServer::where('server_id', '=', intval($id))->delete();
         }
         if (count($id_array) > 1) {
             $servers = '';
             foreach ($server_names as $i => $name) {
                 $servers .= $name;
                 if (count($server_names) > $i + 1) {
                     $servers .= ', ';
                 }
             }
             $result_text = 'The servers ' . $servers . ' were deleted successfully!';
         } else {
             $result_text = 'The server ' . $server_names[0] . ' was deleted successfully!';
         }
         $result_status = 'alert-success';
         $_redirect = '/';
         $_redirect .= $this->_prefix;
         $_redirect .= '/servers';
         return Redirect::to($_redirect)->with('flash_message', $result_text)->with('flash_type', $result_status);
     } catch (QueryException $e) {
         Session::flash('flash_message', 'An error occurred! Please try again.');
         Session::flash('flash_type', 'alert-danger');
         return redirect('/v1/servers')->withInput();
     }
 }