Updated reseller for IP address CRUD
Updated reseller for IP address CRUD
This commit is contained in:
parent
9eafe5fa55
commit
cb2ff263fb
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\IPs;
|
||||
use App\Models\Labels;
|
||||
use App\Models\Locations;
|
||||
use App\Models\Pricing;
|
||||
|
@ -37,9 +38,8 @@ class ResellerController extends Controller
|
|||
$request->validate([
|
||||
'domain' => 'required|min:4',
|
||||
'reseller_type' => 'required',
|
||||
'dedicated_ip' => 'present',
|
||||
'dedicated_ip' => 'present|ip',
|
||||
'accounts' => 'numeric',
|
||||
'has_dedicated_ip' => 'numeric',
|
||||
'server_type' => 'numeric',
|
||||
'ram' => 'numeric',
|
||||
'disk' => 'numeric',
|
||||
|
@ -66,8 +66,6 @@ class ResellerController extends Controller
|
|||
'main_domain' => $request->domain,
|
||||
'accounts' => $request->accounts,
|
||||
'reseller_type' => $request->reseller_type,
|
||||
'has_dedicated_ip' => $request->has_dedicated_ip,
|
||||
'ip' => $request->dedicated_ip,
|
||||
'provider_id' => $request->provider_id,
|
||||
'location_id' => $request->location_id,
|
||||
'disk' => $request->disk,
|
||||
|
@ -98,6 +96,18 @@ class ResellerController extends Controller
|
|||
'next_due_date' => $request->next_due_date,
|
||||
]);
|
||||
|
||||
if (!is_null($request->dedicated_ip)) {
|
||||
IPs::create(
|
||||
[
|
||||
'id' => Str::random(8),
|
||||
'service_id' => $reseller_id,
|
||||
'address' => $request->dedicated_ip,
|
||||
'is_ipv4' => (filter_var($request->dedicated_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? 0 : 1,
|
||||
'active' => 1
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
return redirect()->route('reseller.index')
|
||||
->with('success', 'Reseller hosting created Successfully.');
|
||||
}
|
||||
|
@ -117,7 +127,11 @@ class ResellerController extends Controller
|
|||
->where('l.service_id', '=', $reseller->id)
|
||||
->get(['labels.label']);
|
||||
|
||||
return view('reseller.show', compact(['reseller', 'reseller_extras', 'labels']));
|
||||
$ip_address = DB::table('ips as i')
|
||||
->where('i.service_id', '=', $reseller->id)
|
||||
->get();
|
||||
|
||||
return view('reseller.show', compact(['reseller', 'reseller_extras', 'labels', 'ip_address']));
|
||||
}
|
||||
|
||||
public function edit(Reseller $reseller)
|
||||
|
@ -125,12 +139,16 @@ class ResellerController extends Controller
|
|||
$locations = DB::table('locations')->get(['*']);
|
||||
$providers = json_decode(DB::table('providers')->get(['*']), true);
|
||||
|
||||
$ip_address = json_decode(DB::table('ips as i')
|
||||
->where('i.service_id', '=', $reseller->id)
|
||||
->get(), true);
|
||||
|
||||
$reseller = DB::table('reseller_hosting as s')
|
||||
->join('pricings as p', 's.id', '=', 'p.service_id')
|
||||
->where('s.id', '=', $reseller->id)
|
||||
->get(['s.*', 'p.*']);
|
||||
|
||||
return view('reseller.edit', compact(['reseller', 'locations', 'providers']));
|
||||
return view('reseller.edit', compact(['reseller', 'locations', 'providers', 'ip_address']));
|
||||
}
|
||||
|
||||
public function update(Request $request, Reseller $reseller)
|
||||
|
@ -140,7 +158,6 @@ class ResellerController extends Controller
|
|||
'domain' => 'required|min:4',
|
||||
'reseller_type' => 'required',
|
||||
'dedicated_ip' => 'present',
|
||||
'has_dedicated_ip' => 'numeric',
|
||||
'server_type' => 'numeric',
|
||||
'disk' => 'numeric',
|
||||
'os_id' => 'numeric',
|
||||
|
@ -163,8 +180,6 @@ class ResellerController extends Controller
|
|||
->update([
|
||||
'main_domain' => $request->domain,
|
||||
'reseller_type' => $request->reseller_type,
|
||||
'has_dedicated_ip' => $request->has_dedicated_ip,
|
||||
'ip' => $request->dedicated_ip,
|
||||
'provider_id' => $request->provider_id,
|
||||
'location_id' => $request->location_id,
|
||||
'disk' => $request->disk,
|
||||
|
@ -195,6 +210,17 @@ class ResellerController extends Controller
|
|||
'next_due_date' => $request->next_due_date,
|
||||
]);
|
||||
|
||||
$delete_ip = DB::table('ips')->where('service_id', '=', $request->id)->delete();
|
||||
|
||||
if (isset($request->dedicated_ip)) {
|
||||
DB::insert('INSERT IGNORE INTO ips (id, address, service_id, is_ipv4) values (?, ?, ?, ?)', [
|
||||
Str::random(8),
|
||||
$request->dedicated_ip,
|
||||
$request->id,
|
||||
(filter_var($request->dedicated_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? 0 : 1
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('reseller.index')
|
||||
->with('success', 'Reseller hosting updated Successfully.');
|
||||
}
|
||||
|
@ -207,10 +233,12 @@ class ResellerController extends Controller
|
|||
$items->delete();
|
||||
|
||||
$p = new Pricing();
|
||||
$p->deletePricing($reseller->id);
|
||||
$p->deletePricing($id);
|
||||
|
||||
Labels::deleteLabelsAssignedTo($id);
|
||||
|
||||
IPs::deleteIPsAssignedTo($id);
|
||||
|
||||
return redirect()->route('reseller.index')
|
||||
->with('success', 'Reseller hosting was deleted Successfully.');
|
||||
}
|
||||
|
|
|
@ -17,8 +17,6 @@ class CreateResellersTable extends Migration
|
|||
$table->char('id', 8)->unique();
|
||||
$table->tinyInteger('active')->default(1);
|
||||
$table->string('main_domain');
|
||||
$table->tinyInteger('has_dedicated_ip')->default(0);
|
||||
$table->string('ip')->nullable()->default(null);
|
||||
$table->integer('accounts')->default(1);
|
||||
$table->string('reseller_type')->nullable();
|
||||
$table->integer('provider_id')->default(9999);
|
||||
|
|
|
@ -43,15 +43,7 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-3 mb-3">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend"><span class="input-group-text">Has dedicated IP</span></div>
|
||||
<select class="form-control" name="has_dedicated_ip">
|
||||
<option value="0">No</option>
|
||||
<option value="1">Yes</option>
|
||||
</select></div>
|
||||
</div>
|
||||
<div class="col-12 col-md-3 mb-3">
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend"><span class="input-group-text">Dedicated IP</span></div>
|
||||
<input type="text" name="dedicated_ip" class="form-control"></div>
|
||||
|
|
|
@ -51,13 +51,16 @@
|
|||
value="Webmin" {{ ($reseller[0]->reseller_type === 'Webmin') ? 'selected' : '' }}>
|
||||
Webmin
|
||||
</option>
|
||||
<option value="Moss" {{ ($reseller[0]->reseller_type === 'Moss') ? 'selected' : '' }}>
|
||||
<option
|
||||
value="Moss" {{ ($reseller[0]->reseller_type === 'Moss') ? 'selected' : '' }}>
|
||||
Moss
|
||||
</option>
|
||||
<option value="Other" {{ ($reseller[0]->reseller_type === 'Other') ? 'selected' : '' }}>
|
||||
<option
|
||||
value="Other" {{ ($reseller[0]->reseller_type === 'Other') ? 'selected' : '' }}>
|
||||
Other
|
||||
</option>
|
||||
<option value="Plesk" {{ ($reseller[0]->reseller_type === 'Plesk') ? 'selected' : '' }}>
|
||||
<option
|
||||
value="Plesk" {{ ($reseller[0]->reseller_type === 'Plesk') ? 'selected' : '' }}>
|
||||
Plesk
|
||||
</option>
|
||||
<option
|
||||
|
@ -75,22 +78,13 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-3 mb-3">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend"><span class="input-group-text">Has dedicated IP</span>
|
||||
</div>
|
||||
<select class="form-control" name="has_dedicated_ip">
|
||||
<option value="0" {{ ($reseller[0]->has_dedicated_ip === 0) ? 'selected' : '' }}>No
|
||||
</option>
|
||||
<option value="1" {{ ($reseller[0]->has_dedicated_ip === 1) ? 'selected' : '' }}>Yes
|
||||
</option>
|
||||
</select></div>
|
||||
</div>
|
||||
<div class="col-12 col-md-3 mb-3">
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend"><span class="input-group-text">Dedicated IP</span>
|
||||
</div>
|
||||
<input type="text" name="dedicated_ip" class="form-control" value="{{$reseller[0]->ip}}">
|
||||
<input type="text" name="dedicated_ip" class="form-control" value="
|
||||
@if(isset($ip_address[0]['address']))
|
||||
{{$ip_address[0]['address']}}@endif">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -116,10 +110,12 @@
|
|||
<div class="input-group">
|
||||
<div class="input-group-prepend"><span class="input-group-text">Term</span></div>
|
||||
<select class="form-control" id="payment_term" name="payment_term">
|
||||
<option value="1" {{ ($reseller[0]->term === 1) ? 'selected' : '' }}>Monthly</option>
|
||||
<option value="1" {{ ($reseller[0]->term === 1) ? 'selected' : '' }}>Monthly
|
||||
</option>
|
||||
<option value="2" {{ ($reseller[0]->term === 2) ? 'selected' : '' }}>Quarterly
|
||||
</option>
|
||||
<option value="3" {{ ($reseller[0]->term === 3) ? 'selected' : '' }}>Half annual (half
|
||||
<option value="3" {{ ($reseller[0]->term === 3) ? 'selected' : '' }}>Half annual
|
||||
(half
|
||||
year)
|
||||
</option>
|
||||
<option value="4" {{ ($reseller[0]->term === 4) ? 'selected' : '' }}>Annual (yearly)
|
||||
|
@ -200,7 +196,8 @@
|
|||
<div class="col-12 col-lg-3 mb-4">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend"><span class="input-group-text">Domains</span></div>
|
||||
<input type="number" name="domains" class="form-control" value="{{$reseller[0]->domains_limit}}"
|
||||
<input type="number" name="domains" class="form-control"
|
||||
value="{{$reseller[0]->domains_limit}}"
|
||||
min="1" max="9999">
|
||||
</div>
|
||||
</div>
|
||||
|
@ -214,7 +211,8 @@
|
|||
<div class="col-12 col-lg-3 mb-4">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend"><span class="input-group-text">Disk</span></div>
|
||||
<input type="number" name="disk" class="form-control" value="{{$reseller[0]->disk_as_gb}}"
|
||||
<input type="number" name="disk" class="form-control"
|
||||
value="{{$reseller[0]->disk_as_gb}}"
|
||||
min="1" max="99999">
|
||||
<div class="input-group-append"><span class="input-group-text">GB</span></div>
|
||||
</div>
|
||||
|
@ -222,7 +220,8 @@
|
|||
<div class="col-12 col-lg-3 mb-4">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend"><span class="input-group-text">Email</span></div>
|
||||
<input type="number" name="email" class="form-control" value="{{$reseller[0]->email_limit}}"
|
||||
<input type="number" name="email" class="form-control"
|
||||
value="{{$reseller[0]->email_limit}}"
|
||||
min="1" max="99999">
|
||||
</div>
|
||||
</div>
|
||||
|
@ -241,7 +240,8 @@
|
|||
<div class="col-12 col-lg-3 mb-4">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend"><span class="input-group-text">FTP</span></div>
|
||||
<input type="number" name="ftp" class="form-control" value="{{$reseller[0]->ftp_limit}}" min="1"
|
||||
<input type="number" name="ftp" class="form-control" value="{{$reseller[0]->ftp_limit}}"
|
||||
min="1"
|
||||
max="99999">
|
||||
</div>
|
||||
</div>
|
||||
|
@ -254,7 +254,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-check mt-2">
|
||||
<input class="form-check-input" name="is_active" type="checkbox" value="1" {{ ($reseller[0]->active === 1) ? 'checked' : '' }}>
|
||||
<input class="form-check-input" name="is_active" type="checkbox"
|
||||
value="1" {{ ($reseller[0]->active === 1) ? 'checked' : '' }}>
|
||||
<label class="form-check-label">
|
||||
I still have this server
|
||||
</label>
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="px-2 py-2 font-bold text-muted">Main domain</td>
|
||||
<td><a href="https://{{ $reseller->main_domain }}" class="text-decoration-none">{{ $reseller->main_domain }}</a></td>
|
||||
<td><a href="https://{{ $reseller->main_domain }}"
|
||||
class="text-decoration-none">{{ $reseller->main_domain }}</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-2 py-2 font-bold text-muted">Location</td>
|
||||
|
@ -52,11 +53,20 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="px-2 py-2 font-bold text-muted">Has dedicated IP?</td>
|
||||
<td>{{ ($reseller->has_dedicated_ip)? 'Yes': 'No' }}</td>
|
||||
<td>
|
||||
@if(isset($ip_address[0]->address))
|
||||
Yes
|
||||
@else
|
||||
No
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-2 py-2 font-bold text-muted">IP</td>
|
||||
<td>{{ $reseller->ip }}</td>
|
||||
<td><code>@if(isset($ip_address[0]->address))
|
||||
{{$ip_address[0]->address}}
|
||||
@endif
|
||||
</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="px-2 py-2 font-bold text-muted">Owned since</td>
|
||||
|
|
Loading…
Reference in New Issue
Block a user