mirror of
https://github.com/cp6/my-idlers.git
synced 2024-11-16 15:33:44 +01:00
model(home): refresh servers cache on due date changed
This commit is contained in:
parent
39ffe0712b
commit
6014663a9f
@ -92,6 +92,7 @@ class Home extends Model
|
|||||||
{
|
{
|
||||||
$pricing = new Pricing();
|
$pricing = new Pricing();
|
||||||
$count = $altered_due_soon = 0;
|
$count = $altered_due_soon = 0;
|
||||||
|
$server_due_date_changed = false;
|
||||||
foreach ($due_soon as $service) {
|
foreach ($due_soon as $service) {
|
||||||
if (Carbon::createFromFormat('Y-m-d', $service->next_due_date)->isPast()) {
|
if (Carbon::createFromFormat('Y-m-d', $service->next_due_date)->isPast()) {
|
||||||
$months = $pricing->termAsMonths($service->term);//Get months for term to update the next due date to
|
$months = $pricing->termAsMonths($service->term);//Get months for term to update the next due date to
|
||||||
@ -101,12 +102,20 @@ class Home extends Model
|
|||||||
->update(['next_due_date' => $new_due_date]);
|
->update(['next_due_date' => $new_due_date]);
|
||||||
$due_soon[$count]->next_due_date = $new_due_date;//Update array being sent to view
|
$due_soon[$count]->next_due_date = $new_due_date;//Update array being sent to view
|
||||||
$altered_due_soon = 1;
|
$altered_due_soon = 1;
|
||||||
|
if ($service->service_type === 1) {
|
||||||
|
$server_due_date_changed = true;
|
||||||
|
Server::serverSpecificCacheForget($service->service_id);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
break;//Break because if this date isnt past than the ones after it in the loop wont be either
|
break;//Break because if this date isnt past than the ones after it in the loop wont be either
|
||||||
}
|
}
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($server_due_date_changed) {
|
||||||
|
Server::serverRelatedCacheForget();
|
||||||
|
}
|
||||||
|
|
||||||
if ($altered_due_soon === 1) {//Made changes to due soon so re-write it
|
if ($altered_due_soon === 1) {//Made changes to due soon so re-write it
|
||||||
Cache::put('due_soon', $due_soon);
|
Cache::put('due_soon', $due_soon);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
<td class="text-nowrap">{{ $server->provider_name }}</td>
|
<td class="text-nowrap">{{ $server->provider_name }}</td>
|
||||||
<td class="text-nowrap">{{ $server->price }} {{$server->currency}} {{\App\Process::paymentTermIntToString($server->term)}}</td>
|
<td class="text-nowrap">{{ $server->price }} {{$server->currency}} {{\App\Process::paymentTermIntToString($server->term)}}</td>
|
||||||
<td class="text-nowrap">
|
<td class="text-nowrap">
|
||||||
{{now()->diffInDays(Carbon\Carbon::parse($server->next_due_date))}}
|
{{now()->diffInDays(Carbon\Carbon::parse($server->next_due_date), false)}}
|
||||||
<small>days</small></td>
|
<small>days</small></td>
|
||||||
<td class="text-nowrap"> {{ $server->owned_since }}</td>
|
<td class="text-nowrap"> {{ $server->owned_since }}</td>
|
||||||
<td class="text-nowrap">
|
<td class="text-nowrap">
|
||||||
@ -187,7 +187,8 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
@else
|
@else
|
||||||
<tr>
|
<tr>
|
||||||
<td class="px-4 py-2 border text-red-500" colspan="3">No non-active servers found.</td>
|
<td class="px-4 py-2 border text-red-500" colspan="3">No non-active servers found.
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endif
|
@endif
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user