Преглед на файлове

feat: ✨ Added yearly and half-yearly billing periods

IceToast преди 2 години
родител
ревизия
08208cab72

+ 6 - 0
app/Console/Commands/ChargeServers.php

@@ -61,6 +61,12 @@ class ChargeServers extends Command
                 // check if server is due to be charged by comparing its last_billed date with the current date and the billing period
                 // check if server is due to be charged by comparing its last_billed date with the current date and the billing period
                 $newBillingDate = null;
                 $newBillingDate = null;
                 switch($billing_period) {
                 switch($billing_period) {
+                    case 'yearly':
+                        $newBillingDate = Carbon::parse($server->last_billed)->addYear();
+                        break;
+                    case 'half-yearly':
+                        $newBillingDate = Carbon::parse($server->last_billed)->addMonths(6);
+                        break;
                     case 'monthly':
                     case 'monthly':
                         $newBillingDate = Carbon::parse($server->last_billed)->addMonth();
                         $newBillingDate = Carbon::parse($server->last_billed)->addMonth();
                         break;
                         break;

+ 2 - 2
app/Http/Controllers/Admin/ProductController.php

@@ -73,7 +73,7 @@ class ProductController extends Controller
             "nodes.*" => "required|exists:nodes,id",
             "nodes.*" => "required|exists:nodes,id",
             "eggs.*" => "required|exists:eggs,id",
             "eggs.*" => "required|exists:eggs,id",
             "disabled" => "nullable",
             "disabled" => "nullable",
-            "billing_period" => "required|in:hourly,daily,weekly,monthly",
+            "billing_period" => "required|in:hourly,daily,weekly,monthly,half-yearly,yearly",
         ]);
         ]);
 
 
         $disabled = !is_null($request->input('disabled'));
         $disabled = !is_null($request->input('disabled'));
@@ -140,7 +140,7 @@ class ProductController extends Controller
             "nodes.*" => "required|exists:nodes,id",
             "nodes.*" => "required|exists:nodes,id",
             "eggs.*" => "required|exists:eggs,id",
             "eggs.*" => "required|exists:eggs,id",
             "disabled" => "nullable",
             "disabled" => "nullable",
-            "billing_period" => "required|in:hourly,daily,weekly,monthly",
+            "billing_period" => "required|in:hourly,daily,weekly,monthly,half-yearly,yearly",
         ]);
         ]);
 
 
         $disabled = !is_null($request->input('disabled'));
         $disabled = !is_null($request->input('disabled'));

+ 6 - 0
resources/views/admin/products/create.blade.php

@@ -183,6 +183,12 @@
                                                      <option value="monthly">
                                                      <option value="monthly">
                                                         {{__('Monthly')}}
                                                         {{__('Monthly')}}
                                                     </option>
                                                     </option>
+                                                    <option value="half-yearly">
+                                                        {{__('Half Yearly')}}
+                                                    </option>
+                                                    <option value="yearly">
+                                                        {{__('Yearly')}}
+                                                    </option>
                                             </select>
                                             </select>
                                             @error('billing_period')
                                             @error('billing_period')
                                             <div class="invalid-feedback">
                                             <div class="invalid-feedback">

+ 8 - 0
resources/views/admin/products/edit.blade.php

@@ -190,6 +190,14 @@
                                                      @endif>
                                                      @endif>
                                                         {{__('Monthly')}}
                                                         {{__('Monthly')}}
                                                     </option>
                                                     </option>
+                                                    <option value="half-yearly" @if ($product->billing_period  == 'half-yearly') selected
+                                                    @endif>
+                                                        {{__('Half Yearly')}}
+                                                    </option>
+                                                    <option value="yearly" @if ($product->billing_period  == 'yearly') selected
+                                                    @endif>
+                                                        {{__('Yearly')}}
+                                                    </option>
                                             </select>
                                             </select>
                                             @error('billing_period')
                                             @error('billing_period')
                                             <div class="invalid-feedback">
                                             <div class="invalid-feedback">

+ 4 - 0
resources/views/servers/index.blade.php

@@ -162,6 +162,10 @@
                                         <div class="text-muted">
                                         <div class="text-muted">
                                         @if($server->product->billing_period == 'monthly')
                                         @if($server->product->billing_period == 'monthly')
                                             {{ __('per Month') }}
                                             {{ __('per Month') }}
+                                        @elseif($server->product->billing_period == 'half-yearly')
+                                            {{ __('per 6 Months') }}
+                                        @elseif($server->product->billing_period == 'yearly')
+                                            {{ __('per Year') }}
                                         @elseif($server->product->billing_period == 'weekly')
                                         @elseif($server->product->billing_period == 'weekly')
                                             {{ __('per Week') }}
                                             {{ __('per Week') }}
                                         @elseif($server->product->billing_period == 'daily')
                                         @elseif($server->product->billing_period == 'daily')