1
0
mirror of https://github.com/cp6/my-idlers.git synced 2024-11-16 15:33:44 +01:00

Code cleanup

Removed unused osIdAsString function
Added return types to some functions
This commit is contained in:
cp6 2022-10-05 11:58:19 +11:00
parent 41413a224f
commit b44b4bb259
4 changed files with 8 additions and 72 deletions

View File

@ -200,9 +200,8 @@ class ServerController extends Controller
public function destroy(Server $server)
{
$items = Server::find($server->id);
$items->delete();
$item = Server::find($server->id);
$item->delete();
$p = new Pricing();
$p->deletePricing($server->id);

View File

@ -25,9 +25,9 @@ class IPs extends Model
DB::table('ips')->where('service_id', '=', $service_id)->delete();
}
public static function insertIP(string $service_id, string $address)
public static function insertIP(string $service_id, string $address): IPs
{
self::create(
return self::create(
[
'id' => Str::random(8),
'service_id' => $service_id,

View File

@ -109,7 +109,7 @@ class Pricing extends Model
DB::table('pricings')->where('service_id', '=', $id)->delete();
}
public function insertPricing(int $type, string $service_id, string $currency, float $price, int $term, string $next_due_date, int $is_active = 1)
public function insertPricing(int $type, string $service_id, string $currency, float $price, int $term, string $next_due_date, int $is_active = 1): Pricing
{
$as_usd = $this->convertToUSD($price, $currency);
return self::create([
@ -125,7 +125,7 @@ class Pricing extends Model
]);
}
public function updatePricing(string $service_id, string $currency, float $price, int $term, float $as_usd, string $next_due_date, int $is_active = 1)
public function updatePricing(string $service_id, string $currency, float $price, int $term, float $as_usd, string $next_due_date, int $is_active = 1): int
{
return DB::table('pricings')
->where('service_id', $service_id)

View File

@ -93,7 +93,7 @@ class Server extends Model
}
}
public static function osIntToIcon(int $os, string $os_name)
public static function osIntToIcon(int $os, string $os_name): string
{
if ($os === 1) {//None
return "<i class='fas fa-expand' title='{$os_name}'></i>";
@ -116,70 +116,7 @@ class Server extends Model
}
}
public static function osIdAsString($os)
{
if ($os === "0") {
return "None";
} elseif ($os === "1") {
return "CentOS 7";
} elseif ($os === "2") {
return "CentOS 8";
} elseif ($os === "3") {
return "CentOS";
} elseif ($os === "4") {
return "Debian 9";
} elseif ($os === "5") {
return "Debian 10";
} elseif ($os === "6") {
return "Debian";
} elseif ($os === "7") {
return "Fedora 32";
} elseif ($os === "8") {
return "Fedora 33";
} elseif ($os === "9") {
return "Fedora";
} elseif ($os === "10") {
return "FreeBSD 11.4";
} elseif ($os === "11") {
return "FreeBSD 12.1";
} elseif ($os === "12") {
return "FreeBSD";
} elseif ($os === "13") {
return "OpenBSD 6.7";
} elseif ($os === "14") {
return "OpenBSD 6.8";
} elseif ($os === "15") {
return "OpenBSD";
} elseif ($os == "16") {
return "Ubuntu 16.04";
} elseif ($os === "17") {
return "Ubuntu 18.04";
} elseif ($os === "18") {
return "Ubuntu 20.04";
} elseif ($os === "19") {
return "Ubuntu 20.10";
} elseif ($os === "20") {
return "Ubuntu";
} elseif ($os === "21") {
return "Windows Server 2008";
} elseif ($os === "22") {
return "Windows Server 2012";
} elseif ($os === "23") {
return "Windows Server 2016";
} elseif ($os === "24") {
return "Windows Server 2019";
} elseif ($os === "25") {
return "Windows 10";
} elseif ($os === "26") {
return "Custom";
} elseif ($os === "27") {
return "Other";
} else {
return "Unknown";
}
}
public static function tableRowCompare(string $val1, string $val2, string $value_type = '', bool $is_int = true)
public static function tableRowCompare(string $val1, string $val2, string $value_type = '', bool $is_int = true): string
{
//<td class="td-nowrap plus-td">+303<span class="data-type">MBps</span></td>
$str = '<td class="td-nowrap ';