Added/Updated validation on store and update

Added/Updated validation on store and update
Updated update method in shared, server, seedboxes, reseller and misc
This commit is contained in:
cp6 2022-10-20 11:06:44 +11:00
parent c45df61f10
commit a649f1749e
12 changed files with 289 additions and 230 deletions

View File

@ -34,9 +34,13 @@ class DNSController extends Controller
public function store(Request $request)
{
$request->validate([
'hostname' => 'required|min:2',
'address' => 'required|min:2',
'dns_type' => 'required'
'hostname' => 'required|string|min:2',
'address' => 'required|string|min:2',
'dns_type' => 'required|string',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$dns_id = Str::random(8);
@ -90,9 +94,13 @@ class DNSController extends Controller
public function update(Request $request, DNS $dn)
{
$request->validate([
'hostname' => 'required|min:2',
'address' => 'required|min:2',
'dns_type' => 'required'
'hostname' => 'required|string|min:2',
'address' => 'required|string|min:2',
'dns_type' => 'required|string',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$dn->update([

View File

@ -34,11 +34,20 @@ class DomainsController extends Controller
public function store(Request $request)
{
$request->validate([
'domain' => 'required|min:2',
'extension' => 'required|min:2',
'provider_id' => 'numeric',
'domain' => 'required|string|min:2',
'extension' => 'required|string|min:2',
'ns1' => 'sometimes|nullable|min:2',
'ns2' => 'sometimes|nullable|min:2',
'ns3' => 'sometimes|nullable|min:2',
'provider_id' => 'integer',
'payment_term' => 'integer',
'price' => 'numeric',
'next_due_date' => 'required|date'
'next_due_date' => 'required|date',
'owned_since' => 'sometimes|nullable|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$domain_id = Str::random(8);
@ -74,10 +83,20 @@ class DomainsController extends Controller
public function update(Request $request, Domains $domain)
{
$request->validate([
'domain' => 'required|min:2',
'extension' => 'required|min:2',
'provider_id' => 'numeric',
'price' => 'numeric'
'domain' => 'required|string|min:2',
'extension' => 'required|string|min:2',
'ns1' => 'sometimes|nullable|min:2',
'ns2' => 'sometimes|nullable|min:2',
'ns3' => 'sometimes|nullable|min:2',
'provider_id' => 'integer',
'payment_term' => 'integer',
'price' => 'numeric',
'next_due_date' => 'required|date',
'owned_since' => 'sometimes|nullable|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$pricing = new Pricing();

View File

@ -31,7 +31,8 @@ class IPsController extends Controller
{
$request->validate([
'address' => 'required|ip|min:2',
'ip_type' => 'required'
'ip_type' => 'required|string|size:4',
'service_id' => 'required|string'
]);
$ip_id = Str::random(8);

View File

@ -25,7 +25,7 @@ class LabelsController extends Controller
public function store(Request $request)
{
$request->validate([
'label' => 'required|min:2'
'label' => 'required|string|min:2'
]);
Labels::create([

View File

@ -24,7 +24,7 @@ class LocationsController extends Controller
public function store(Request $request)
{
$request->validate([
'location_name' => 'required|min:2'
'location_name' => 'required|string|min:2'
]);
Locations::create([

View File

@ -32,9 +32,11 @@ class MiscController extends Controller
public function store(Request $request)
{
$request->validate([
'name' => 'required|min:3',
'name' => 'required|string|min:3',
'price' => 'required|numeric',
'owned_since' => 'date',
'payment_term' => 'required|integer',
'currency' => 'required|string|size:3',
'owned_since' => 'sometimes|nullable|date',
'next_due_date' => 'required|date'
]);
@ -65,13 +67,15 @@ class MiscController extends Controller
public function update(Request $request, Misc $misc)
{
$request->validate([
'name' => 'required',
'owned_since' => 'date',
'name' => 'required|string|min:3',
'price' => 'required|numeric',
'payment_term' => 'required|integer',
'currency' => 'required|string|size:3',
'owned_since' => 'sometimes|nullable|date',
'next_due_date' => 'required|date'
]);
DB::table('misc_services')
->where('id', $misc->id)
->update([
$misc->update([
'name' => $request->name,
'owned_since' => $request->owned_since,
'active' => (isset($request->is_active)) ? 1 : 0

View File

@ -22,7 +22,7 @@ class OsController extends Controller
public function store(Request $request)
{
$request->validate([
'os_name' => 'required|min:2'
'os_name' => 'required|string|min:2'
]);
OS::create([

View File

@ -24,7 +24,7 @@ class ProvidersController extends Controller
public function store(Request $request)
{
$request->validate([
'provider_name' => 'required|min:2'
'provider_name' => 'required|string|min:2'
]);
Providers::create([

View File

@ -31,26 +31,27 @@ class ResellerController extends Controller
{
$request->validate([
'domain' => 'required|min:4',
'reseller_type' => 'required',
'dedicated_ip' => 'present',
'accounts' => 'numeric',
'server_type' => 'numeric',
'ram' => 'numeric',
'disk' => 'numeric',
'os_id' => 'numeric',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'reseller_type' => 'required|string',
'disk' => 'integer',
'os_id' => 'integer',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'numeric',
'was_promo' => 'numeric',
'owned_since' => 'date',
'domains' => 'numeric',
'sub_domains' => 'numeric',
'bandwidth' => 'numeric',
'email' => 'numeric',
'ftp' => 'numeric',
'db' => 'numeric',
'next_due_date' => 'required|date'
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'accounts' => 'integer',
'domains' => 'integer',
'sub_domains' => 'integer',
'bandwidth' => 'integer',
'email' => 'integer',
'ftp' => 'integer',
'db' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$reseller_id = Str::random(8);
@ -106,30 +107,31 @@ class ResellerController extends Controller
public function update(Request $request, Reseller $reseller)
{
$request->validate([
'id' => 'required|size:8',
'domain' => 'required|min:4',
'reseller_type' => 'required',
'dedicated_ip' => 'present',
'server_type' => 'numeric',
'disk' => 'numeric',
'os_id' => 'numeric',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'reseller_type' => 'required|string',
'disk' => 'integer',
'os_id' => 'integer',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'numeric',
'was_promo' => 'numeric',
'owned_since' => 'date',
'domains' => 'numeric',
'sub_domains' => 'numeric',
'bandwidth' => 'numeric',
'email' => 'numeric',
'ftp' => 'numeric',
'db' => 'numeric'
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'accounts' => 'integer',
'domains' => 'integer',
'sub_domains' => 'integer',
'bandwidth' => 'integer',
'email' => 'integer',
'ftp' => 'integer',
'db' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
DB::table('reseller_hosting')
->where('id', $request->id)
->update([
$reseller->update([
'main_domain' => $request->domain,
'reseller_type' => $request->reseller_type,
'provider_id' => $request->provider_id,

View File

@ -29,19 +29,23 @@ class SeedBoxesController extends Controller
public function store(Request $request)
{
$request->validate([
'title' => 'required|string',
'hostname' => 'string|nullable',
'seed_box_type' => 'required',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'title' => 'required|string|min:2',
'hostname' => 'sometimes|nullable|string|min:2',
'seed_box_type' => 'required|string',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'numeric',
'was_promo' => 'numeric',
'owned_since' => 'date',
'disk' => 'numeric',
'bandwidth' => 'numeric',
'port_speed' => 'numeric',
'next_due_date' => 'required|date'
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'disk' => 'integer',
'bandwidth' => 'integer',
'port_speed' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$seedbox_id = Str::random(8);
@ -91,24 +95,26 @@ class SeedBoxesController extends Controller
public function update(Request $request, SeedBoxes $seedbox)
{
$request->validate([
'id' => 'required|size:8',
'title' => 'required|string',
'hostname' => 'string|nullable',
'seed_box_type' => 'required',
'disk' => 'numeric',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'title' => 'required|string|min:2',
'hostname' => 'sometimes|nullable|string|min:2',
'seed_box_type' => 'required|string',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'numeric',
'was_promo' => 'numeric',
'owned_since' => 'date',
'bandwidth' => 'numeric',
'port_speed' => 'numeric'
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'disk' => 'integer',
'bandwidth' => 'integer',
'port_speed' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
DB::table('seedboxes')
->where('id', $seedbox->id)
->update([
$seedbox->update([
'title' => $request->title,
'hostname' => $request->hostname,
'seed_box_type' => $request->seed_box_type,

View File

@ -18,9 +18,7 @@ class ServerController extends Controller
public function index()
{
$servers = Server::allActiveServers();
$non_active_servers = Server::allNonActiveServers();
return view('servers.index', compact(['servers', 'non_active_servers']));
}
@ -43,22 +41,30 @@ class ServerController extends Controller
public function store(Request $request)
{
$request->validate([
'hostname' => 'required|min:5',
'ip1' => 'nullable|ip',
'ip2' => 'nullable|ip',
'service_type' => 'numeric',
'server_type' => 'numeric',
'ram' => 'numeric',
'disk' => 'numeric',
'os_id' => 'numeric',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'price' => 'numeric',
'cpu' => 'numeric',
'was_promo' => 'numeric',
'next_due_date' => 'required|date'
'ip1' => 'sometimes|nullable|ip',
'ip2' => 'sometimes|nullable|ip',
'ns1' => 'sometimes|nullable|string',
'ns2' => 'sometimes|nullable|string',
'service_type' => 'integer',
'server_type' => 'integer',
'ssh_port' => 'integer',
'bandwidth' => 'integer',
'ram' => 'required|numeric',
'disk' => 'required|integer',
'os_id' => 'required|integer',
'provider_id' => 'required|integer',
'location_id' => 'required|integer',
'price' => 'required|numeric',
'cpu' => 'required|integer',
'was_promo' => 'integer',
'next_due_date' => 'required|date',
'owned_since' => 'sometimes|nullable|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$server_id = Str::random(8);
@ -123,22 +129,31 @@ class ServerController extends Controller
{
$request->validate([
'hostname' => 'required|min:5',
'ram' => 'numeric',
'disk' => 'numeric',
'os_id' => 'numeric',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'price' => 'numeric',
'cpu' => 'numeric',
'was_promo' => 'numeric',
'next_due_date' => 'date'
'ip1' => 'sometimes|nullable|ip',
'ip2' => 'sometimes|nullable|ip',
'ns1' => 'sometimes|nullable|string',
'ns2' => 'sometimes|nullable|string',
'service_type' => 'integer',
'server_type' => 'integer',
'ssh_port' => 'integer',
'bandwidth' => 'integer',
'ram' => 'required|numeric',
'disk' => 'required|integer',
'os_id' => 'required|integer',
'provider_id' => 'required|integer',
'location_id' => 'required|integer',
'price' => 'required|numeric',
'cpu' => 'required|integer',
'was_promo' => 'integer',
'next_due_date' => 'required|date',
'owned_since' => 'sometimes|nullable|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$server_id = $request->server_id;
DB::table('servers')
->where('id', $server_id)
->update([
$server->update([
'hostname' => $request->hostname,
'server_type' => $request->server_type,
'os_id' => $request->os_id,
@ -161,6 +176,8 @@ class ServerController extends Controller
'show_public' => (isset($request->show_public)) ? 1 : 0
]);
$server_id = $request->server_id;
$pricing = new Pricing();
$as_usd = $pricing->convertToUSD($request->price, $request->currency);
@ -209,7 +226,7 @@ class ServerController extends Controller
{//NOTICE: Selecting servers is not cached yet
$all_servers = Server::where('has_yabs', 1)->get();
if (isset($all_servers[1])){
if (isset($all_servers[1])) {
return view('servers.choose-compare', compact('all_servers'));
}

View File

@ -29,24 +29,26 @@ class SharedController extends Controller
{
$request->validate([
'domain' => 'required|min:4',
'shared_type' => 'required',
'server_type' => 'numeric',
'ram' => 'numeric',
'disk' => 'numeric',
'os_id' => 'numeric',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'shared_type' => 'required|string',
'disk' => 'integer',
'os_id' => 'integer',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'numeric',
'was_promo' => 'numeric',
'owned_since' => 'date',
'domains' => 'numeric',
'sub_domains' => 'numeric',
'bandwidth' => 'numeric',
'email' => 'numeric',
'ftp' => 'numeric',
'db' => 'numeric',
'next_due_date' => 'required|date'
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'domains' => 'integer',
'sub_domains' => 'integer',
'bandwidth' => 'integer',
'email' => 'integer',
'ftp' => 'integer',
'db' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
$shared_id = Str::random(8);
@ -103,30 +105,30 @@ class SharedController extends Controller
public function update(Request $request, Shared $shared)
{
$request->validate([
'id' => 'required|size:8',
'domain' => 'required|min:4',
'shared_type' => 'required',
'dedicated_ip' => 'present',
'server_type' => 'numeric',
'disk' => 'numeric',
'os_id' => 'numeric',
'provider_id' => 'numeric',
'location_id' => 'numeric',
'shared_type' => 'required|string',
'disk' => 'integer',
'os_id' => 'integer',
'provider_id' => 'integer',
'location_id' => 'integer',
'price' => 'numeric',
'payment_term' => 'numeric',
'was_promo' => 'numeric',
'owned_since' => 'date',
'domains' => 'numeric',
'sub_domains' => 'numeric',
'bandwidth' => 'numeric',
'email' => 'numeric',
'ftp' => 'numeric',
'db' => 'numeric'
'payment_term' => 'integer',
'was_promo' => 'integer',
'owned_since' => 'sometimes|nullable|date',
'domains' => 'integer',
'sub_domains' => 'integer',
'bandwidth' => 'integer',
'email' => 'integer',
'ftp' => 'integer',
'db' => 'integer',
'next_due_date' => 'required|date',
'label1' => 'sometimes|nullable|string',
'label2' => 'sometimes|nullable|string',
'label3' => 'sometimes|nullable|string',
'label4' => 'sometimes|nullable|string',
]);
DB::table('shared_hosting')
->where('id', $request->id)
->update([
$shared->update([
'main_domain' => $request->domain,
'shared_type' => $request->shared_type,
'provider_id' => $request->provider_id,