From bc4b19650a1addb4f9b26a359db4c823a53f9b8e Mon Sep 17 00:00:00 2001 From: cp6 Date: Wed, 2 Mar 2022 13:52:55 +1100 Subject: [PATCH] Added show_public for servers Added show_public for servers --- app/Http/Controllers/ServerController.php | 11 +++++--- app/Models/Server.php | 2 +- ...2021_02_10_122904_create_servers_table.php | 1 + resources/views/servers/create.blade.php | 9 ++++++- resources/views/servers/edit.blade.php | 26 ++++++++++++++----- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php index 5c2df1c..a0e3e78 100644 --- a/app/Http/Controllers/ServerController.php +++ b/app/Http/Controllers/ServerController.php @@ -51,8 +51,8 @@ class ServerController extends Controller Session::put('show_server_value_provider', $settings[0]->show_server_value_provider); Session::put('show_server_value_location', $settings[0]->show_server_value_location); Session::save(); - - if ((Session::has('show_servers_public') && Session::get('show_servers_public') === 1) || Auth::check()) { + + if ((Session::get('show_servers_public') === 1)) { $servers = DB::table('servers as s') ->Join('pricings as pr', 's.id', '=', 'pr.service_id') ->Join('providers as p', 's.provider_id', '=', 'p.id') @@ -60,6 +60,7 @@ class ServerController extends Controller ->Join('os as o', 's.os_id', '=', 'o.id') ->LeftJoin('yabs as y', 's.id', '=', 'y.server_id') ->LeftJoin('disk_speed as ds', 'y.id', '=', 'ds.id') + ->where('s.show_public', '=', 1) ->get(['pr.currency', 'pr.price', 'pr.term', 'pr.as_usd', 'pr.next_due_date', 'pr.service_id', 'p.name as provider_name', 'l.name as location', 'o.name as os_name', 'y.*', 'y.id as yabs_id', 'ds.*', 's.*']); return view('servers.public-index', compact('servers')); @@ -116,7 +117,8 @@ class ServerController extends Controller 'ns2' => $request->ns2, 'bandwidth' => $request->bandwidth, 'cpu' => $request->cpu, - 'was_promo' => $request->was_promo + 'was_promo' => $request->was_promo, + 'show_public' => $request->show_public ]); if (!is_null($request->ip1)) { @@ -262,7 +264,8 @@ class ServerController extends Controller 'bandwidth' => $request->bandwidth, 'cpu' => $request->cpu, 'was_promo' => $request->was_promo, - 'active' => (isset($request->is_active)) ? 1 : 0 + 'active' => (isset($request->is_active)) ? 1 : 0, + 'show_public' => (isset($request->show_public)) ? 1 : 0 ]); $pricing = new Pricing(); diff --git a/app/Models/Server.php b/app/Models/Server.php index 8b75a20..b8ffe8b 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -11,7 +11,7 @@ class Server extends Model public $incrementing = false; - protected $fillable = ['id', 'hostname', 'ipv4', 'ipv6', 'server_type', 'os_id', 'location_id', 'provider_id', 'ram', 'disk', 'ram_type', 'disk_type', 'ns1', 'ns2', 'label', 'bandwidth', 'ram_as_mb', 'disk_as_gb', 'has_yabs', 'was_promo', 'owned_since', 'ssh', 'active']; + protected $fillable = ['id', 'hostname', 'ipv4', 'ipv6', 'server_type', 'os_id', 'location_id', 'provider_id', 'ram', 'disk', 'ram_type', 'disk_type', 'ns1', 'ns2', 'label', 'bandwidth', 'ram_as_mb', 'disk_as_gb', 'has_yabs', 'was_promo', 'owned_since', 'ssh', 'active','show_public']; /** * @var mixed */ diff --git a/database/migrations/2021_02_10_122904_create_servers_table.php b/database/migrations/2021_02_10_122904_create_servers_table.php index 7f23895..65b26c4 100644 --- a/database/migrations/2021_02_10_122904_create_servers_table.php +++ b/database/migrations/2021_02_10_122904_create_servers_table.php @@ -16,6 +16,7 @@ class CreateServersTable extends Migration Schema::create('servers', function (Blueprint $table) { $table->char('id', 8)->unique()->default(null); $table->tinyInteger('active')->default(1); + $table->tinyInteger('show_public')->default(0); $table->string('hostname'); $table->string('ns1')->nullable()->default(null); $table->string('ns2')->nullable()->default(null); diff --git a/resources/views/servers/create.blade.php b/resources/views/servers/create.blade.php index be757be..ea98d8b 100644 --- a/resources/views/servers/create.blade.php +++ b/resources/views/servers/create.blade.php @@ -237,7 +237,14 @@ - +
+ + +
Insert server diff --git a/resources/views/servers/edit.blade.php b/resources/views/servers/edit.blade.php index 654830f..6871ee4 100644 --- a/resources/views/servers/edit.blade.php +++ b/resources/views/servers/edit.blade.php @@ -264,12 +264,26 @@
@endforeach
-
- active === 1) ? 'checked' : '' }}> - +
+
+
+ active === 1) ? 'checked' : '' }}> + +
+
+
+
+ show_public === 1) ? 'checked' : '' }}> + +
+