diff --git a/app/Console/Commands/MoonRental/ExecuteSendMoonRentalInvoices.php b/app/Console/Commands/MoonRental/ExecuteSendMoonRentalInvoices.php
new file mode 100644
index 000000000..5e29874a3
--- /dev/null
+++ b/app/Console/Commands/MoonRental/ExecuteSendMoonRentalInvoices.php
@@ -0,0 +1,42 @@
+ $rentalAmount,
]);
}
+ */
return 0;
}
diff --git a/app/Http/Controllers/MiningTaxes/MiningTaxesAdminController.php b/app/Http/Controllers/MiningTaxes/MiningTaxesAdminController.php
index ee9ac44f5..f4a39f832 100644
--- a/app/Http/Controllers/MiningTaxes/MiningTaxesAdminController.php
+++ b/app/Http/Controllers/MiningTaxes/MiningTaxesAdminController.php
@@ -109,6 +109,20 @@ class MiningTaxesAdminController extends Controller
return redirect('/admin/dashboard')->with('success', 'Operation added successfully.');
}
+ /**
+ * Display the page to approve corporation moon rentals
+ */
+ public function DisplayMoonRentalRequests() {
+
+ }
+
+ /**
+ * Approve a moon rental from the form
+ */
+ public function storeApproveMoonRentalRequest() {
+
+ }
+
/**
* Display the page to setup the form for corporations to rent a moon
*/
diff --git a/app/Http/Controllers/MiningTaxes/MiningTaxesController.php b/app/Http/Controllers/MiningTaxes/MiningTaxesController.php
index 852a81124..ece8ff17e 100644
--- a/app/Http/Controllers/MiningTaxes/MiningTaxesController.php
+++ b/app/Http/Controllers/MiningTaxes/MiningTaxesController.php
@@ -31,6 +31,7 @@ use App\Models\Esi\EsiScope;
use App\Models\User\User;
use App\Models\MoonRental\AllianceMoon;
use App\Models\MoonRental\AllianceMoonOre;
+use App\Models\MoonRental\AllianceMoonRental;
class MiningTaxesController extends Controller
{
@@ -42,6 +43,85 @@ class MiningTaxesController extends Controller
$this->middleware('role:User');
}
+ /**
+ * Display the page with the moon rental form
+ */
+ public function DisplayMoonRentalForm(Request $request) {
+ $this->validate($request, [
+ 'moon_id' => 'required',
+ 'moon_name' => 'required',
+ 'worth_amount' => 'required',
+ 'rental_amount' => 'required',
+ ]);
+
+ $moon = AllianceMoon::where([
+ 'moon_id' => $request->moon_id,
+ ])->first();
+
+ $ores = AllianceMoonOre::where([
+ 'moon_id' => $request->moon_id,
+ ])->get();
+
+ return view('minintax.user.moonrentals.form')->with('moon', $moon)
+ ->with('ores', $ores);
+ }
+
+ /**
+ * Store the information from the moon rental form
+ */
+ public function storeMoonRentalForm(Request $request) {
+ $this->validate($request, [
+ 'moon_id' => 'required',
+ 'moon_name' => 'required',
+ 'rental_start' => 'required',
+ 'rental_end' => 'required',
+ 'entity_name' => 'required',
+ 'entity_type' => 'reuqired',
+ ]);
+
+ $lookup = new LookupHelper;
+ $entityId = null;
+
+ //From the name and type of the entity get the entity id.
+ if($request->entity_type == 'Character') {
+ $entityId = $lookup->CharacterNameToId();
+ } else if($request->entity_type == 'Corporation') {
+ $entityId = $lookup->CorporationNameToId();
+ } else if($request->entity_type == 'Alliance') {
+ $entityId = $lookup->AllianceNameToId();
+ } else {
+ return redirect('error', 'Moon Rental error. Please contact the site admin.');
+ }
+
+ //Create the next billing date from a Carbon date 3 months from the rental start
+ $nextBillingDate = Carbon::create($request->rental_end)->addMonths(3);
+
+ //Create the uniqid for the billing cycle.
+ $invoiceId = "MR" . uniqid();
+
+ //Update the data on the Alliance Moon
+ AllianceMoon::where([
+ 'moon_id' => $request->moon_id,
+ ])->update([
+ 'rented' => 'Yes',
+ ]);
+
+ //Insert a new moon rental into the database
+ AllianceMoonRental::insert([
+ 'moon_id' => $request->moon_id,
+ 'moon_name' => $request->moon_name,
+ 'rental_amount' => $rentalAmount,
+ 'rental_start' => $request->rental_start,
+ 'rental_end' => $request->rental_end,
+ 'next_billing_date' => $nextBillingDate,
+ 'entity_id' => $entityId,
+ 'entity_name' => $request->entity_name,
+ 'entity_type' => $request->entity_type,
+ ]);
+
+ return redirect('/dashboard')->with('success', 'Before placing a structure please send the ISK to the holding corp with the description of ' . $invoiceId);
+ }
+
public function displayAvailableMoons() {
//Declare variables
$moons = new Collection;
@@ -106,6 +186,9 @@ class MiningTaxesController extends Controller
'system' => $moon->system_name,
'moon_name' => $moon->name,
'ores' => $ores,
+ 'worth_amount' => $moon->worth_amount,
+ 'rental_amount' => $moon->rental_amount,
+ 'moon_id' => $moon->moon_id,
]);
}
}
diff --git a/app/Jobs/Commands/MoonRental/Invoices/SendMoonRentalInvoices.php b/app/Jobs/Commands/MoonRental/Invoices/SendMoonRentalInvoices.php
new file mode 100644
index 000000000..284ff3be1
--- /dev/null
+++ b/app/Jobs/Commands/MoonRental/Invoices/SendMoonRentalInvoices.php
@@ -0,0 +1,51 @@
+connection = 'redis';
+ $this->onQueue('miningtaxes');
+ }
+
+ /**
+ * Execute the job.
+ *
+ * @return void
+ */
+ public function handle()
+ {
+ //Declare variables
+ $lookup = new LookupHelper;
+ $months = 3;
+ $today = Carbon::now();
+ $future = Carbon::now()->addMonths(3);
+ }
+}
diff --git a/resources/views/miningtax/user/display/moonrentals/form.blade.php b/resources/views/miningtax/user/display/moonrentals/form.blade.php
new file mode 100644
index 000000000..f0fce3a1b
--- /dev/null
+++ b/resources/views/miningtax/user/display/moonrentals/form.blade.php
@@ -0,0 +1,38 @@
+@extends('layouts.user.dashb4')
+@section('content')
+
+