Added labels for shared hosting services

Added labels for shared hosting services
This commit is contained in:
cp6 2022-02-20 16:39:40 +11:00
parent 508bca32bd
commit c892295de7
3 changed files with 97 additions and 8 deletions

View File

@ -96,6 +96,14 @@ class SharedController extends Controller
'next_due_date' => $request->next_due_date, 'next_due_date' => $request->next_due_date,
]); ]);
$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)], $shared_id]);
}
}
return redirect()->route('shared.index') return redirect()->route('shared.index')
->with('success', 'Shared hosting created Successfully.'); ->with('success', 'Shared hosting created Successfully.');
} }
@ -121,14 +129,17 @@ class SharedController extends Controller
{ {
$locations = DB::table('locations')->get(['*']); $locations = DB::table('locations')->get(['*']);
$providers = json_decode(DB::table('providers')->get(['*']), true); $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', '=', $shared->id)
->get(['labels.id', 'labels.label']);
$shared = DB::table('shared_hosting as s') $shared = DB::table('shared_hosting as s')
->join('pricings as p', 's.id', '=', 'p.service_id') ->join('pricings as p', 's.id', '=', 'p.service_id')
->where('s.id', '=', $shared->id) ->where('s.id', '=', $shared->id)
->get(['s.*', 'p.*']); ->get(['s.*', 'p.*']);
return view('shared.edit', compact(['shared', 'locations', 'providers', 'labels']));
return view('shared.edit', compact(['shared', 'locations', 'providers']));
} }
public function update(Request $request, Shared $shared) public function update(Request $request, Shared $shared)
@ -193,6 +204,16 @@ class SharedController extends Controller
'next_due_date' => $request->next_due_date, '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]);
}
}
return redirect()->route('shared.index') return redirect()->route('shared.index')
->with('success', 'Shared hosting updated Successfully.'); ->with('success', 'Shared hosting updated Successfully.');
} }

View File

@ -190,6 +190,32 @@
</div> </div>
</div> </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> <div>
<button type="submit" <button type="submit"
class="btn btn-success py-0 px-4 mt-2"> class="btn btn-success py-0 px-4 mt-2">

View File

@ -161,9 +161,9 @@
</div> </div>
<select class="form-control" name="location_id"> <select class="form-control" name="location_id">
<option value="999">Null</option> <option value="999">Null</option>
@foreach ($locations as $loc) @foreach ($locations as $item)
<option <option
value="{{ $loc->id }}" {{ ( $loc->id === $shared[0]->provider_id) ? 'selected' : '' }}> {{ $loc ->name }} </option> value="{{ $item->id }}" {{ ( $item->id === $shared[0]->location_id) ? 'selected' : '' }}> {{ $item->name }} </option>
@endforeach @endforeach
</select> </select>
</div> </div>
@ -200,7 +200,8 @@
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Domains</span></div> <div class="input-group-prepend"><span class="input-group-text">Domains</span></div>
<input type="number" name="domains" class="form-control" value="{{$shared[0]->domains_limit}}" <input type="number" name="domains" class="form-control"
value="{{$shared[0]->domains_limit}}"
min="1" max="9999"> min="1" max="9999">
</div> </div>
</div> </div>
@ -222,7 +223,8 @@
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">Email</span></div> <div class="input-group-prepend"><span class="input-group-text">Email</span></div>
<input type="number" name="email" class="form-control" value="{{$shared[0]->email_limit}}" <input type="number" name="email" class="form-control"
value="{{$shared[0]->email_limit}}"
min="1" max="99999"> min="1" max="99999">
</div> </div>
</div> </div>
@ -241,7 +243,8 @@
<div class="col-12 col-lg-3 mb-4"> <div class="col-12 col-lg-3 mb-4">
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"><span class="input-group-text">FTP</span></div> <div class="input-group-prepend"><span class="input-group-text">FTP</span></div>
<input type="number" name="ftp" class="form-control" value="{{$shared[0]->ftp_limit}}" min="1" <input type="number" name="ftp" class="form-control" value="{{$shared[0]->ftp_limit}}"
min="1"
max="99999"> max="99999">
</div> </div>
</div> </div>
@ -253,8 +256,47 @@
</div> </div>
</div> </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"> <div class="form-check mt-2">
<input class="form-check-input" name="is_active" type="checkbox" value="1" {{ ($shared[0]->active === 1) ? 'checked' : '' }}> <input class="form-check-input" name="is_active" type="checkbox"
value="1" {{ ($shared[0]->active === 1) ? 'checked' : '' }}>
<label class="form-check-label"> <label class="form-check-label">
I still have this server I still have this server
</label> </label>