Added settings for due soon & recently added amounts

Added settings for due soon & recently added amounts tables on the homepage
This commit is contained in:
cp6 2022-03-09 13:41:12 +11:00
parent 4688dd15ca
commit e9123763f8
5 changed files with 205 additions and 133 deletions

View File

@ -46,7 +46,7 @@ class HomeController extends Controller
->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id')
->where('p.active', '=', 1)
->orderBy('next_due_date', 'ASC')
->limit(6)
->limit(Session::get('due_soon_amount'))
->get(['p.*', 's.hostname', 'd.domain', 'd.extension', 'r.main_domain as reseller', 'sh.main_domain', 'ms.name']);
});
@ -95,7 +95,7 @@ class HomeController extends Controller
->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id')
->where('p.active', '=', 1)
->orderBy('created_at', 'DESC')
->limit(6)
->limit(Session::get('recently_added_amount'))
->get(['p.*', 's.hostname', 'd.domain', 'd.extension', 'r.main_domain as reseller', 'sh.main_domain', 'ms.name']);
});
@ -115,6 +115,8 @@ class HomeController extends Controller
Session::put('show_server_value_location', $settings[0]->show_server_value_location);
Session::put('default_currency', $settings[0]->default_currency);
Session::put('default_server_os', $settings[0]->default_server_os);
Session::put('due_soon_amount', $settings[0]->due_soon_amount);
Session::put('recently_added_amount', $settings[0]->recently_added_amount);
Session::save();
$pricing = json_decode(DB::table('pricings')->get(), true);

View File

@ -30,7 +30,9 @@ class SettingsController extends Controller
'show_server_value_price' => 'required|boolean',
'show_server_value_yabs' => 'required|boolean',
'default_currency' => 'required',
'default_server_os' => 'required'
'default_server_os' => 'required',
'due_soon_amount' => 'required|integer|between:0,12',
'recently_added_amount' => 'required|integer|between:0,12'
]);
DB::table('settings')
@ -45,7 +47,9 @@ class SettingsController extends Controller
'show_server_value_price' => $request->show_server_value_price,
'show_server_value_yabs' => $request->show_server_value_yabs,
'default_currency' => $request->default_currency,
'default_server_os' => $request->default_server_os
'default_server_os' => $request->default_server_os,
'due_soon_amount' => $request->due_soon_amount,
'recently_added_amount' => $request->recently_added_amount
]);
Session::put('timer_version_footer', $request->show_versions_footer);
@ -58,8 +62,13 @@ class SettingsController extends Controller
Session::put('show_server_value_location', $request->show_server_value_location);
Session::put('default_currency', $request->default_currency);
Session::put('default_server_os', $request->default_server_os);
Session::put('due_soon_amount', $request->due_soon_amount);
Session::put('recently_added_amount', $request->recently_added_amount);
Session::save();
Cache::forget('due_soon');//Main page due_soon cache
Cache::forget('recently_added');//Main page recently_added cache
Cache::forget('settings');//Main page settings cache
return redirect()->route('settings.index')

View File

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->integer('due_soon_amount')->default(6);
$table->integer('recently_added_amount')->default(6);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('settings', function (Blueprint $table) {
//
});
}
};

View File

@ -204,148 +204,152 @@
</div>
</div>
<h3 class="my-3">Due soon</h3>
@if(!empty($information['due_soon']))
<div class="card shadow mt-3">
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered">
<thead class="table-light">
<tr>
<th class="text-nowrap">Name</th>
<th class="text-nowrap">Type</th>
<th class="text-nowrap">Due</th>
<th class="text-nowrap">Price</th>
<th class="text-nowrap"></th>
</tr>
</thead>
<tbody>
@foreach($information['due_soon'] as $due_soon)
@if(Session::get('due_soon_amount') > 0)
<h3 class="my-3">Due soon</h3>
@if(!empty($information['due_soon']))
<div class="card shadow mt-3">
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered">
<thead class="table-light">
<tr>
<td class="text-nowrap">
@if($due_soon->service_type === 1)
{{$due_soon->hostname}}
@elseif($due_soon->service_type === 2)
{{$due_soon->main_domain}}
@elseif($due_soon->service_type === 3)
{{$due_soon->reseller}}
@elseif($due_soon->service_type === 4)
{{$due_soon->domain}}.{{$due_soon->extension}}
@elseif($due_soon->service_type === 5)
{{$due_soon->name}}
@endif
</td>
<td class="text-nowrap">
@if($due_soon->service_type === 1)
VPS
@elseif($due_soon->service_type === 2)
Shared
@elseif($due_soon->service_type === 3)
Reseller
@elseif($due_soon->service_type === 4)
Domain
@elseif($due_soon->service_type === 5)
Misc
@endif
</td>
<td class="text-nowrap">
{{Carbon\Carbon::parse($due_soon->next_due_date)->diffForHumans()}}</td>
<td class="text-nowrap">{{$due_soon->price}} {{$due_soon->currency}} {{\App\Process::paymentTermIntToString($due_soon->term)}}</td>
<td class="text-nowrap text-center">
@if($due_soon->service_type === 1)
<a href="{{ route('servers.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($due_soon->service_type === 2)
<a href="{{ route('shared.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($due_soon->service_type === 3)
<a href="{{ route('reseller.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($due_soon->service_type === 4)
<a href="{{ route('domains.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($due_soon->service_type === 5)
<a href="{{ route('misc.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@endif
</td>
<th class="text-nowrap">Name</th>
<th class="text-nowrap">Type</th>
<th class="text-nowrap">Due</th>
<th class="text-nowrap">Price</th>
<th class="text-nowrap"></th>
</tr>
@endforeach
</tbody>
</table>
</thead>
<tbody>
@foreach($information['due_soon'] as $due_soon)
<tr>
<td class="text-nowrap">
@if($due_soon->service_type === 1)
{{$due_soon->hostname}}
@elseif($due_soon->service_type === 2)
{{$due_soon->main_domain}}
@elseif($due_soon->service_type === 3)
{{$due_soon->reseller}}
@elseif($due_soon->service_type === 4)
{{$due_soon->domain}}.{{$due_soon->extension}}
@elseif($due_soon->service_type === 5)
{{$due_soon->name}}
@endif
</td>
<td class="text-nowrap">
@if($due_soon->service_type === 1)
VPS
@elseif($due_soon->service_type === 2)
Shared
@elseif($due_soon->service_type === 3)
Reseller
@elseif($due_soon->service_type === 4)
Domain
@elseif($due_soon->service_type === 5)
Misc
@endif
</td>
<td class="text-nowrap">
{{Carbon\Carbon::parse($due_soon->next_due_date)->diffForHumans()}}</td>
<td class="text-nowrap">{{$due_soon->price}} {{$due_soon->currency}} {{\App\Process::paymentTermIntToString($due_soon->term)}}</td>
<td class="text-nowrap text-center">
@if($due_soon->service_type === 1)
<a href="{{ route('servers.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($due_soon->service_type === 2)
<a href="{{ route('shared.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($due_soon->service_type === 3)
<a href="{{ route('reseller.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($due_soon->service_type === 4)
<a href="{{ route('domains.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@elseif($due_soon->service_type === 5)
<a href="{{ route('misc.show', $due_soon->service_id) }}"
class="text-body mx-1"><i class="fas fa-eye"
title="view"></i></a>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endif
@endif
<h3 class="mt-4">Recently added</h3>
@if(!empty($information['newest']))
<div class="card shadow mt-3">
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered">
<thead class="table-light">
<tr>
<th class="text-nowrap">Name</th>
<th class="text-nowrap">Type</th>
<th class="text-nowrap">Added</th>
<th class="text-nowrap">Price</th>
<th class="text-nowrap"></th>
</tr>
</thead>
<tbody>
@foreach($information['newest'] as $new)
@if(Session::get('recently_added_amount') > 0)
<h3 class="mt-4">Recently added</h3>
@if(!empty($information['newest']))
<div class="card shadow mt-3">
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered">
<thead class="table-light">
<tr>
<td class="text-nowrap">
@if($new->service_type === 1)
{{$new->hostname}}
@elseif($new->service_type === 2)
{{$new->main_domain}}
@elseif($new->service_type === 3)
{{$new->reseller}}
@elseif($new->service_type === 4)
{{$new->domain}}.{{$new->extension}}
@elseif($new->service_type === 5)
{{$new->name}}
@endif
</td>
<td class="text-nowrap">
@if($new->service_type === 1)
VPS
@elseif($new->service_type === 2)
Shared
@elseif($new->service_type === 3)
Reseller
@elseif($new->service_type === 4)
Domain
@elseif($new->service_type === 5)
Misc
@endif
</td>
<td class="text-nowrap">{{Carbon\Carbon::parse($new->created_at)->diffForHumans()}}</td>
<td class="text-nowrap">{{$new->price}} {{$new->currency}} {{\App\Process::paymentTermIntToString($new->term)}}</td>
<td class="text-nowrap text-center">
<a href="{{ route('servers.show', $new->service_id) }}"
class="text-body mx-1">
<i class="fas fa-eye" title="view"></i>
</a>
</td>
<th class="text-nowrap">Name</th>
<th class="text-nowrap">Type</th>
<th class="text-nowrap">Added</th>
<th class="text-nowrap">Price</th>
<th class="text-nowrap"></th>
</tr>
@endforeach
</tbody>
</table>
</thead>
<tbody>
@foreach($information['newest'] as $new)
<tr>
<td class="text-nowrap">
@if($new->service_type === 1)
{{$new->hostname}}
@elseif($new->service_type === 2)
{{$new->main_domain}}
@elseif($new->service_type === 3)
{{$new->reseller}}
@elseif($new->service_type === 4)
{{$new->domain}}.{{$new->extension}}
@elseif($new->service_type === 5)
{{$new->name}}
@endif
</td>
<td class="text-nowrap">
@if($new->service_type === 1)
VPS
@elseif($new->service_type === 2)
Shared
@elseif($new->service_type === 3)
Reseller
@elseif($new->service_type === 4)
Domain
@elseif($new->service_type === 5)
Misc
@endif
</td>
<td class="text-nowrap">{{Carbon\Carbon::parse($new->created_at)->diffForHumans()}}</td>
<td class="text-nowrap">{{$new->price}} {{$new->currency}} {{\App\Process::paymentTermIntToString($new->term)}}</td>
<td class="text-nowrap text-center">
<a href="{{ route('servers.show', $new->service_id) }}"
class="text-body mx-1">
<i class="fas fa-eye" title="view"></i>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endif
@endif
@if(Session::has('timer_version_footer') && Session::get('timer_version_footer') === 1)
<p class="text-muted mt-4 text-end"><small>Page took {{$information['execution_time']}} seconds,
Built on Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }}

View File

@ -174,6 +174,30 @@
</x-currency-select>
</div>
</div>
<div class="row mt-3">
<div class="col-12 col-md-4 mb-3">
<x-number-input>
<x-slot name="title">Due soon amount to show</x-slot>
<x-slot name="name">due_soon_amount</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="min">0</x-slot>
<x-slot name="max">12</x-slot>
<x-slot name="value">{{$setting[0]->due_soon_amount}}</x-slot>
</x-number-input>
</div>
</div>
<div class="row mt-3">
<div class="col-12 col-md-4 mb-3">
<x-number-input>
<x-slot name="title">Recently added amount to show</x-slot>
<x-slot name="name">recently_added_amount</x-slot>
<x-slot name="step">1</x-slot>
<x-slot name="min">0</x-slot>
<x-slot name="max">12</x-slot>
<x-slot name="value">{{$setting[0]->recently_added_amount}}</x-slot>
</x-number-input>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-4">
<x-submit-button>Update settings</x-submit-button>