Added show_public for servers

Added show_public for servers
This commit is contained in:
cp6 2022-03-02 13:52:55 +11:00
parent 8dd2ee6393
commit bc4b19650a
5 changed files with 37 additions and 12 deletions

View File

@ -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_provider', $settings[0]->show_server_value_provider);
Session::put('show_server_value_location', $settings[0]->show_server_value_location); Session::put('show_server_value_location', $settings[0]->show_server_value_location);
Session::save(); 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') $servers = DB::table('servers as s')
->Join('pricings as pr', 's.id', '=', 'pr.service_id') ->Join('pricings as pr', 's.id', '=', 'pr.service_id')
->Join('providers as p', 's.provider_id', '=', 'p.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') ->Join('os as o', 's.os_id', '=', 'o.id')
->LeftJoin('yabs as y', 's.id', '=', 'y.server_id') ->LeftJoin('yabs as y', 's.id', '=', 'y.server_id')
->LeftJoin('disk_speed as ds', 'y.id', '=', 'ds.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.*']); ->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')); return view('servers.public-index', compact('servers'));
@ -116,7 +117,8 @@ class ServerController extends Controller
'ns2' => $request->ns2, 'ns2' => $request->ns2,
'bandwidth' => $request->bandwidth, 'bandwidth' => $request->bandwidth,
'cpu' => $request->cpu, 'cpu' => $request->cpu,
'was_promo' => $request->was_promo 'was_promo' => $request->was_promo,
'show_public' => $request->show_public
]); ]);
if (!is_null($request->ip1)) { if (!is_null($request->ip1)) {
@ -262,7 +264,8 @@ class ServerController extends Controller
'bandwidth' => $request->bandwidth, 'bandwidth' => $request->bandwidth,
'cpu' => $request->cpu, 'cpu' => $request->cpu,
'was_promo' => $request->was_promo, '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(); $pricing = new Pricing();

View File

@ -11,7 +11,7 @@ class Server extends Model
public $incrementing = false; 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 * @var mixed
*/ */

View File

@ -16,6 +16,7 @@ class CreateServersTable extends Migration
Schema::create('servers', function (Blueprint $table) { Schema::create('servers', function (Blueprint $table) {
$table->char('id', 8)->unique()->default(null); $table->char('id', 8)->unique()->default(null);
$table->tinyInteger('active')->default(1); $table->tinyInteger('active')->default(1);
$table->tinyInteger('show_public')->default(0);
$table->string('hostname'); $table->string('hostname');
$table->string('ns1')->nullable()->default(null); $table->string('ns1')->nullable()->default(null);
$table->string('ns2')->nullable()->default(null); $table->string('ns2')->nullable()->default(null);

View File

@ -237,7 +237,14 @@
</x-labels-select> </x-labels-select>
</div> </div>
</div> </div>
<div class="form-check">
<input class="form-check-input" name="show_public" type="checkbox"
value="1">
<label class="form-check-label">
Allow this data to be public <a href="{{route('settings.index')}}">restrict values
here</a>
</label>
</div>
<div class="row"> <div class="row">
<div class="col-12 col-lg-4"> <div class="col-12 col-lg-4">
<x-submit-button>Insert server</x-submit-button> <x-submit-button>Insert server</x-submit-button>

View File

@ -264,12 +264,26 @@
</div> </div>
@endforeach @endforeach
</div> </div>
<div class="form-check mt-3"> <div class="row mt-2">
<input class="form-check-input" name="is_active" type="checkbox" <div class="col-12 col-lg-6 mb-4">
value="1" {{ ($server[0]->active === 1) ? 'checked' : '' }}> <div class="form-check">
<label class="form-check-label"> <input class="form-check-input" name="is_active" type="checkbox"
I still have this server value="1" {{ ($server[0]->active === 1) ? 'checked' : '' }}>
</label> <label class="form-check-label">
I still have this server
</label>
</div>
</div>
<div class="col-12 col-lg-6 mb-4">
<div class="form-check">
<input class="form-check-input" name="show_public" type="checkbox"
value="1" {{ ($server[0]->show_public === 1) ? 'checked' : '' }}>
<label class="form-check-label">
Allow this data to be public <a href="{{route('settings.index')}}">restrict values
here</a>
</label>
</div>
</div>
</div> </div>
<div class="row mt-2"> <div class="row mt-2">
<div class="col-12 col-lg-4"> <div class="col-12 col-lg-4">