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') ->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id')
->where('p.active', '=', 1) ->where('p.active', '=', 1)
->orderBy('next_due_date', 'ASC') ->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']); ->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') ->leftJoin('misc_services as ms', 'p.service_id', '=', 'ms.id')
->where('p.active', '=', 1) ->where('p.active', '=', 1)
->orderBy('created_at', 'DESC') ->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']); ->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('show_server_value_location', $settings[0]->show_server_value_location);
Session::put('default_currency', $settings[0]->default_currency); Session::put('default_currency', $settings[0]->default_currency);
Session::put('default_server_os', $settings[0]->default_server_os); 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(); Session::save();
$pricing = json_decode(DB::table('pricings')->get(), true); $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_price' => 'required|boolean',
'show_server_value_yabs' => 'required|boolean', 'show_server_value_yabs' => 'required|boolean',
'default_currency' => 'required', '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') DB::table('settings')
@ -45,7 +47,9 @@ class SettingsController extends Controller
'show_server_value_price' => $request->show_server_value_price, 'show_server_value_price' => $request->show_server_value_price,
'show_server_value_yabs' => $request->show_server_value_yabs, 'show_server_value_yabs' => $request->show_server_value_yabs,
'default_currency' => $request->default_currency, '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); 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('show_server_value_location', $request->show_server_value_location);
Session::put('default_currency', $request->default_currency); Session::put('default_currency', $request->default_currency);
Session::put('default_server_os', $request->default_server_os); 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(); 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 Cache::forget('settings');//Main page settings cache
return redirect()->route('settings.index') 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,7 +204,7 @@
</div> </div>
</div> </div>
@if(Session::get('due_soon_amount') > 0)
<h3 class="my-3">Due soon</h3> <h3 class="my-3">Due soon</h3>
@if(!empty($information['due_soon'])) @if(!empty($information['due_soon']))
<div class="card shadow mt-3"> <div class="card shadow mt-3">
@ -284,7 +284,9 @@
</div> </div>
</div> </div>
@endif @endif
@endif
@if(Session::get('recently_added_amount') > 0)
<h3 class="mt-4">Recently added</h3> <h3 class="mt-4">Recently added</h3>
@if(!empty($information['newest'])) @if(!empty($information['newest']))
<div class="card shadow mt-3"> <div class="card shadow mt-3">
@ -346,6 +348,8 @@
</div> </div>
</div> </div>
@endif @endif
@endif
@if(Session::has('timer_version_footer') && Session::get('timer_version_footer') === 1) @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, <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 }} Built on Laravel v{{ Illuminate\Foundation\Application::VERSION }} (PHP v{{ PHP_VERSION }}

View File

@ -174,6 +174,30 @@
</x-currency-select> </x-currency-select>
</div> </div>
</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="row">
<div class="col-12 col-lg-4"> <div class="col-12 col-lg-4">
<x-submit-button>Update settings</x-submit-button> <x-submit-button>Update settings</x-submit-button>