From e9123763f8126c2158cb6379f331fc68be6293a3 Mon Sep 17 00:00:00 2001 From: cp6 Date: Wed, 9 Mar 2022 13:41:12 +1100 Subject: [PATCH] Added settings for due soon & recently added amounts Added settings for due soon & recently added amounts tables on the homepage --- app/Http/Controllers/HomeController.php | 6 +- app/Http/Controllers/SettingsController.php | 13 +- ...9_add_homepage_amount_cols_to_settings.php | 33 +++ resources/views/home.blade.php | 262 +++++++++--------- resources/views/settings/index.blade.php | 24 ++ 5 files changed, 205 insertions(+), 133 deletions(-) create mode 100644 database/migrations/2022_03_09_022939_add_homepage_amount_cols_to_settings.php diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index a8b43a4..3895cb2 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -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); diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 892caa8..dfae00f 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -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') diff --git a/database/migrations/2022_03_09_022939_add_homepage_amount_cols_to_settings.php b/database/migrations/2022_03_09_022939_add_homepage_amount_cols_to_settings.php new file mode 100644 index 0000000..456e446 --- /dev/null +++ b/database/migrations/2022_03_09_022939_add_homepage_amount_cols_to_settings.php @@ -0,0 +1,33 @@ +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) { + // + }); + } +}; diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 0e5e563..7844415 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -204,148 +204,152 @@ - -

Due soon

- @if(!empty($information['due_soon'])) -
-
-
- - - - - - - - - - - - @foreach($information['due_soon'] as $due_soon) + @if(Session::get('due_soon_amount') > 0) +

Due soon

+ @if(!empty($information['due_soon'])) +
+
+
+
NameTypeDuePrice
+ - - - - - + + + + + - @endforeach - -
- @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 - - @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 - - {{Carbon\Carbon::parse($due_soon->next_due_date)->diffForHumans()}}{{$due_soon->price}} {{$due_soon->currency}} {{\App\Process::paymentTermIntToString($due_soon->term)}} - @if($due_soon->service_type === 1) - - @elseif($due_soon->service_type === 2) - - @elseif($due_soon->service_type === 3) - - @elseif($due_soon->service_type === 4) - - @elseif($due_soon->service_type === 5) - - @endif - NameTypeDuePrice
+ + + @foreach($information['due_soon'] as $due_soon) + + + @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 + + + @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 + + + {{Carbon\Carbon::parse($due_soon->next_due_date)->diffForHumans()}} + {{$due_soon->price}} {{$due_soon->currency}} {{\App\Process::paymentTermIntToString($due_soon->term)}} + + @if($due_soon->service_type === 1) + + @elseif($due_soon->service_type === 2) + + @elseif($due_soon->service_type === 3) + + @elseif($due_soon->service_type === 4) + + @elseif($due_soon->service_type === 5) + + @endif + + + @endforeach + + +
- + @endif @endif -

Recently added

- @if(!empty($information['newest'])) -
-
-
- - - - - - - - - - - - @foreach($information['newest'] as $new) + @if(Session::get('recently_added_amount') > 0) +

Recently added

+ @if(!empty($information['newest'])) +
+
+
+
NameTypeAddedPrice
+ - - - - - + + + + + - @endforeach - -
- @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 - - @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 - {{Carbon\Carbon::parse($new->created_at)->diffForHumans()}}{{$new->price}} {{$new->currency}} {{\App\Process::paymentTermIntToString($new->term)}} - - - - NameTypeAddedPrice
+ + + @foreach($information['newest'] as $new) + + + @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 + + + @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 + + {{Carbon\Carbon::parse($new->created_at)->diffForHumans()}} + {{$new->price}} {{$new->currency}} {{\App\Process::paymentTermIntToString($new->term)}} + + + + + + + @endforeach + + +
- + @endif @endif + @if(Session::has('timer_version_footer') && Session::get('timer_version_footer') === 1)

Page took {{$information['execution_time']}} seconds, Built on Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }} diff --git a/resources/views/settings/index.blade.php b/resources/views/settings/index.blade.php index 99ce061..ebfa76b 100644 --- a/resources/views/settings/index.blade.php +++ b/resources/views/settings/index.blade.php @@ -174,6 +174,30 @@ +

+
+ + Due soon amount to show + due_soon_amount + 1 + 0 + 12 + {{$setting[0]->due_soon_amount}} + +
+
+
+
+ + Recently added amount to show + recently_added_amount + 1 + 0 + 12 + {{$setting[0]->recently_added_amount}} + +
+
Update settings