Added labels for reseller services

Added labels for reseller services
This commit is contained in:
cp6 2022-03-02 01:36:59 +11:00
parent 53a1059e69
commit 8dd2ee6393
3 changed files with 88 additions and 1 deletions

View File

@ -109,6 +109,14 @@ class ResellerController extends Controller
);
}
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4];
for ($i = 1; $i <= 4; $i++) {
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT IGNORE INTO labels_assigned (label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $reseller_id]);
}
}
Cache::forget('services_count');//Main page services_count cache
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
@ -144,6 +152,11 @@ class ResellerController extends Controller
$locations = DB::table('locations')->get(['*']);
$providers = json_decode(DB::table('providers')->get(['*']), true);
$labels = DB::table('labels_assigned as l')
->join('labels', 'l.label_id', '=', 'labels.id')
->where('l.service_id', '=', $reseller->id)
->get(['labels.id', 'labels.label']);
$ip_address = json_decode(DB::table('ips as i')
->where('i.service_id', '=', $reseller->id)
->get(), true);
@ -153,7 +166,7 @@ class ResellerController extends Controller
->where('s.id', '=', $reseller->id)
->get(['s.*', 'p.*']);
return view('reseller.edit', compact(['reseller', 'locations', 'providers', 'ip_address']));
return view('reseller.edit', compact(['reseller', 'locations', 'providers', 'ip_address', 'labels']));
}
public function update(Request $request, Reseller $reseller)
@ -215,6 +228,16 @@ class ResellerController extends Controller
'next_due_date' => $request->next_due_date,
]);
$deleted = DB::table('labels_assigned')->where('service_id', '=', $request->id)->delete();
$labels_array = [$request->label1, $request->label2, $request->label3, $request->label4];
for ($i = 1; $i <= 4; $i++) {
if (!is_null($labels_array[($i - 1)])) {
DB::insert('INSERT IGNORE INTO labels_assigned ( label_id, service_id) values (?, ?)', [$labels_array[($i - 1)], $request->id]);
}
}
$delete_ip = DB::table('ips')->where('service_id', '=', $request->id)->delete();
if (isset($request->dedicated_ip)) {

View File

@ -188,6 +188,32 @@
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label1</x-slot>
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label2</x-slot>
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label3</x-slot>
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label4</x-slot>
</x-labels-select>
</div>
</div>
<div>
<button type="submit"
class="btn btn-success py-0 px-4 mt-2">

View File

@ -253,6 +253,44 @@
</div>
</div>
</div>
<div class="row mb-3">
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label1</x-slot>
@if(isset($labels[0]->id))
<x-slot name="current">{{$labels[0]->id}}</x-slot>
@endif
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label2</x-slot>
@if(isset($labels[1]->id))
<x-slot name="current">{{$labels[1]->id}}</x-slot>
@endif
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label3</x-slot>
@if(isset($labels[2]->id))
<x-slot name="current">{{$labels[2]->id}}</x-slot>
@endif
</x-labels-select>
</div>
<div class="col-12 col-lg-3 mb-4">
<x-labels-select>
<x-slot name="title">label</x-slot>
<x-slot name="name">label4</x-slot>
@if(isset($labels[3]->id))
<x-slot name="current">{{$labels[3]->id}}</x-slot>
@endif
</x-labels-select>
</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' : '' }}>