removed files and transferred others to the new system. this is going to break so much shit.
This commit is contained in:
@@ -16,8 +16,8 @@ use App\Models\Moon\RentalMoon;
|
||||
use App\Models\Moon\OrePrice;
|
||||
use App\Models\Moon\Price;
|
||||
//use App\Models\MoonRent\MoonRental;
|
||||
//use App\Models\Moon\AllianceMoon;
|
||||
use App\Models\MoonRent\AllianceRentalMoon;
|
||||
use App\Models\Moon\AllianceMoon;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Moon\AllianceMoonRequest;
|
||||
|
||||
//Library
|
||||
@@ -140,7 +140,7 @@ class MoonsAdminController extends Controller
|
||||
* Function to display the ability for the admins to update moons with who is renting,
|
||||
* and when it ends
|
||||
*/
|
||||
public function updateMoonNew() {
|
||||
public function updateMoon() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare the variables we need
|
||||
@@ -180,7 +180,7 @@ class MoonsAdminController extends Controller
|
||||
* New function based on new table. Will
|
||||
* update description in a future update.
|
||||
*/
|
||||
public function storeMoonRemovalNew(Request $request) {
|
||||
public function storeMoonRemoval(Request $request) {
|
||||
//Check for the correct role for the user to utilize this function
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
@@ -218,7 +218,7 @@ class MoonsAdminController extends Controller
|
||||
* New function based on new table. Will
|
||||
* update description in a future update.
|
||||
*/
|
||||
public function displayRentalMoonsAdminNew() {
|
||||
public function displayRentalMoonsAdmin() {
|
||||
//Declare variables for the function
|
||||
$lookupHelper = new LookupHelper;
|
||||
$moonCalc = new MoonCalc;
|
||||
@@ -346,193 +346,6 @@ class MoonsAdminController extends Controller
|
||||
return view('moons.admin.adminmoon')->with('table', $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons to admins
|
||||
*/
|
||||
public function displayRentalMoonsAdmin() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$lookupHelper = new LookupHelper;
|
||||
$contact = '';
|
||||
$paid = '';
|
||||
$rentalEnd = '';
|
||||
$renter = '';
|
||||
$ticker = '';
|
||||
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//Get all of the moons from the database
|
||||
$moons = RentalMoon::orderBy('System', 'asc')->get();
|
||||
//Declare the html variable and set it to null
|
||||
$table = array();
|
||||
//Set carbon dates as needed
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
$today = Carbon::now();
|
||||
|
||||
foreach($moons as $moon) {
|
||||
//Get the rental data for the moon
|
||||
$count = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->count();
|
||||
|
||||
//Check if their is a current rental for a moon going on
|
||||
if($count == 0) {
|
||||
//If we don't find a rental record, mark the moon as not paid
|
||||
$paid = 'No';
|
||||
|
||||
//If we don't find a rental record, set the rental date as last month
|
||||
$rentalTemp = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//If we don't find a rental record, set the paid until date as last month
|
||||
$paidUntilTemp = $lastMonth;
|
||||
$paidUntil = $paidUntilTemp->format('m-d');
|
||||
|
||||
//Set the contact info
|
||||
$contact = 'None';
|
||||
|
||||
//Set the renter info
|
||||
$renter = 'None';
|
||||
|
||||
//Set the ticker info
|
||||
$ticker = 'N/A';
|
||||
|
||||
//Set the type info as it's needed
|
||||
$type = 'N/A';
|
||||
} else {
|
||||
//Get the rental data for the moon
|
||||
$rental = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->first();
|
||||
|
||||
//If we find a rental record, mark the moon as whether it's paid or not
|
||||
$paid = $rental->Paid;
|
||||
$paidUntil = new Carbon($rental->Paid_Until);
|
||||
$paidUntil = $paidUntil->format('m-d');
|
||||
|
||||
//Set the rental date up
|
||||
$rentalTemp = new Carbon($rental->RentalEnd);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
|
||||
//Set the contact name
|
||||
$contact = $lookupHelper->CharacterIdToName($rental->Contact);
|
||||
|
||||
//Set up the renter whether it's a corporation in W4RP or another alliance
|
||||
$ticker = $rental->RentalCorp;
|
||||
$type = $rental->Type;
|
||||
}
|
||||
|
||||
//Set the color for the table
|
||||
if($rentalTemp->diffInDays($today) < 3 ) {
|
||||
$color = 'table-warning';
|
||||
} else if( $today > $rentalTemp) {
|
||||
$color = 'table-success';
|
||||
} else {
|
||||
$color = 'table-danger';
|
||||
}
|
||||
|
||||
//Calculate the price of the moon based on what is in the moon
|
||||
$price = $moonCalc->SpatialMoons($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity, $moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
//Add the data to the html string to be passed to the view
|
||||
array_push($table, [
|
||||
'SPM' => $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon,
|
||||
'StructureName' => $moon->StructureName,
|
||||
'AlliancePrice' => $price['alliance'],
|
||||
'OutOfAlliancePrice' => $price['outofalliance'],
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
'Paid' => $paid,
|
||||
'PaidUntil' => $paidUntil,
|
||||
'Contact' => $contact,
|
||||
'Type' => $type,
|
||||
'Renter' => $ticker,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('moons.admin.adminmoon')->with('table', $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to remove a renter from a moon
|
||||
*/
|
||||
public function storeMoonRemoval(Request $request) {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
$this->validate($request, [
|
||||
'remove' => 'required',
|
||||
]);
|
||||
|
||||
$str_array = explode(" - ", $request->remove);
|
||||
|
||||
//Decode the value for the SPM into a system, planet, and moon for the database to update
|
||||
$system = $str_array[0];
|
||||
$planet = $str_array[1];
|
||||
$moon = $str_array[2];
|
||||
|
||||
$found = MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->count();
|
||||
|
||||
if($found != 0) {
|
||||
MoonRental::where([
|
||||
'System' => $system,
|
||||
'Planet' => $planet,
|
||||
'Moon' => $moon,
|
||||
])->delete();
|
||||
|
||||
return redirect('/moons/admin/display/rentals')->with('success', 'Renter removed.');
|
||||
}
|
||||
|
||||
//Redirect back to the moon page, which should call the page to be displayed correctly
|
||||
return redirect('/moons/admin/display/rentals')->with('error', 'Something went wrong.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function displays the ability for admins to update moons with who is renting, and when it ends.
|
||||
*/
|
||||
public function updateMoon() {
|
||||
$this->middleware('role:Admin');
|
||||
|
||||
//Declare some variables
|
||||
$system = null;
|
||||
$planet = null;
|
||||
$moon = null;
|
||||
$name = null;
|
||||
$spmnTemp = array();
|
||||
$spmn = array();
|
||||
|
||||
//Get the moons and put in order by System, Planet, then Moon number
|
||||
$moons = RentalMoon::orderBy('System', 'ASC')
|
||||
->orderBy('Planet', 'ASC')
|
||||
->orderBy('Moon', 'ASC')
|
||||
->get();
|
||||
|
||||
//Push our default value onto the stack
|
||||
array_push($spmn, 'N/A');
|
||||
|
||||
//Form our array of strings for each system, planet, and moon combination.
|
||||
foreach($moons as $m) {
|
||||
$temp = $m->System . " - " . $m->Planet . " - " . $m->Moon . " - " . $m->StructureName;
|
||||
array_push($spmnTemp, $temp);
|
||||
}
|
||||
|
||||
//From our temporary array with all the values in a numbered key, create the real array with the value being the key
|
||||
foreach($spmnTemp as $key => $value) {
|
||||
$spmn[$value] = $value;
|
||||
}
|
||||
|
||||
//Return the view and the form from the blade display
|
||||
//Pass the data to the view as well
|
||||
return view('moons.admin.updatemoon')->with('spmn', $spmn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the updated moon
|
||||
*/
|
||||
|
||||
@@ -15,8 +15,9 @@ use App\Models\Moon\ItemComposition;
|
||||
use App\Models\Moon\RentalMoon;
|
||||
use App\Models\Moon\OrePrice;
|
||||
use App\Models\Moon\Price;
|
||||
use App\Models\MoonRent\MoonRental;
|
||||
//use App\Models\MoonRent\MoonRental;
|
||||
use App\Models\Moon\AllianceMoon;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
use App\Models\Moon\AllianceMoonRequest;
|
||||
|
||||
//Library
|
||||
@@ -219,7 +220,7 @@ class MoonsController extends Controller
|
||||
* Function to display the moons and pass to the blade template
|
||||
* Function description will be updated in a future release.
|
||||
*/
|
||||
public function displayRentalMoonsNew() {
|
||||
public function displayRentalMoons() {
|
||||
//Declare variables
|
||||
$rentalEnd = null;
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
@@ -294,87 +295,6 @@ class MoonsController extends Controller
|
||||
return view('moons.user.moon')->with('table', $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to display the moons and pass data to the blade template
|
||||
*/
|
||||
public function displayRentalMoons() {
|
||||
$rentalEnd = '';
|
||||
|
||||
//Get the user type from the user Auth class
|
||||
$type = Auth::user()->getUserType();
|
||||
//Setup calls to the MoonCalc class
|
||||
$moonCalc = new MoonCalc();
|
||||
//get all of the rental moons from the database
|
||||
$moons = DB::table('RentalMoons')->orderBy('System', 'asc')->get();
|
||||
//Set the rental date as last month for moons not rented
|
||||
$lastMonth = Carbon::now()->subMonth();
|
||||
//Set a variable for today's date
|
||||
$today = Carbon::now();
|
||||
|
||||
//declare the html variable and set it to null
|
||||
|
||||
$table = array();
|
||||
$moonprice = null;
|
||||
foreach($moons as $moon) {
|
||||
//get the rental data for the moon
|
||||
$rental = MoonRental::where([
|
||||
'System' => $moon->System,
|
||||
'Planet' => $moon->Planet,
|
||||
'Moon' => $moon->Moon,
|
||||
])->first();
|
||||
|
||||
if($rental == false) {
|
||||
//If we don't find a rental record, set the rental date as last month
|
||||
$rentalTemp = $lastMonth;
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
} else {
|
||||
//Set the rental date up
|
||||
$rentalTemp = new Carbon($rental->RentalEnd);
|
||||
$rentalEnd = $rentalTemp->format('m-d');
|
||||
}
|
||||
|
||||
$price = $moonCalc->SpatialMoons($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
$worth = $moonCalc->SpatialMoonsTotalWorth($moon->FirstOre, $moon->FirstQuantity, $moon->SecondOre, $moon->SecondQuantity,
|
||||
$moon->ThirdOre, $moon->ThirdQuantity, $moon->FourthOre, $moon->FourthQuantity);
|
||||
|
||||
if($type == 'W4RP') {
|
||||
$moonprice = $price['alliance'];
|
||||
} else {
|
||||
$moonprice = $price['outofalliance'];
|
||||
}
|
||||
|
||||
if($rentalTemp->diffInDays($today) < 3 ) {
|
||||
$color = 'table-warning';
|
||||
} else if( $today > $rentalTemp) {
|
||||
$color = 'table-primary';
|
||||
} else {
|
||||
$color = 'table-danger';
|
||||
}
|
||||
|
||||
//Add the data to the html string to be passed to the view
|
||||
array_push($table, [
|
||||
'SPM' => $moon->System . ' - ' . $moon->Planet . ' - ' . $moon->Moon,
|
||||
'StructureName' => $moon->StructureName,
|
||||
'FirstOre' => $moon->FirstOre,
|
||||
'FirstQuantity' => $moon->FirstQuantity,
|
||||
'SecondOre' => $moon->SecondOre,
|
||||
'SecondQuantity' => $moon->SecondQuantity,
|
||||
'ThirdOre' => $moon->ThirdOre,
|
||||
'ThirdQuantity' => $moon->ThirdQuantity,
|
||||
'FourthOre' => $moon->FourthOre,
|
||||
'FourthQuantity' => $moon->FourthQuantity,
|
||||
'Price' => number_format($moonprice, 0, ".", ","),
|
||||
'Worth' => number_format($worth, 0, ".", ","),
|
||||
'RentalEnd' => $rentalEnd,
|
||||
'RowColor' => $color,
|
||||
]);
|
||||
}
|
||||
|
||||
return view('moons.user.moon')->with('table', $table);
|
||||
}
|
||||
|
||||
public function displayTotalWorthForm() {
|
||||
return view('moons.user.formTotalWorth');
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\MoonRent;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MoonRental extends Model
|
||||
{
|
||||
// Table Name
|
||||
protected $table = 'moon_rents';
|
||||
|
||||
//Primary Key
|
||||
public $primaryKey = 'id';
|
||||
|
||||
//Timestamps
|
||||
public $timestamps = false;
|
||||
|
||||
//Fillable Items
|
||||
protected $fillable = [
|
||||
'System',
|
||||
'Planet',
|
||||
'Moon',
|
||||
'StructureId',
|
||||
'RentalCorp',
|
||||
'RentalEnd',
|
||||
'Contact',
|
||||
'Type',
|
||||
'Price',
|
||||
'Paid',
|
||||
'Paid_Until',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user