blacklist modifications and moon admin new stuff
This commit is contained in:
@@ -83,6 +83,8 @@ class BlacklistController extends Controller
|
|||||||
return redirect('/blacklist/display/add')->with('error', 'Entity Id was not found.');
|
return redirect('/blacklist/display/add')->with('error', 'Entity Id was not found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Store the entity in the table
|
//Store the entity in the table
|
||||||
BlacklistEntity::insert([
|
BlacklistEntity::insert([
|
||||||
'entity_id' => $entityId,
|
'entity_id' => $entityId,
|
||||||
@@ -92,6 +94,7 @@ class BlacklistController extends Controller
|
|||||||
'alts' => $request->alts,
|
'alts' => $request->alts,
|
||||||
'lister_id' => auth()->user()->getId(),
|
'lister_id' => auth()->user()->getId(),
|
||||||
'lister_name' => auth()->user()->getName(),
|
'lister_name' => auth()->user()->getName(),
|
||||||
|
'validity' => 'Valid',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//Return to the view
|
//Return to the view
|
||||||
@@ -132,7 +135,9 @@ class BlacklistController extends Controller
|
|||||||
public function DisplayBlacklist() {
|
public function DisplayBlacklist() {
|
||||||
|
|
||||||
//Get the entire blacklist
|
//Get the entire blacklist
|
||||||
$blacklist = BlacklistEntity::orderBy('entity_name', 'asc')->paginate(50);
|
$blacklist = BlacklistEntity::where([
|
||||||
|
'validity' => 'Valid',
|
||||||
|
])->orderBy('entity_name', 'asc')->paginate(50);
|
||||||
|
|
||||||
//Return the view with the data
|
//Return the view with the data
|
||||||
return view('blacklist.list')->with('blacklist', $blacklist);
|
return view('blacklist.list')->with('blacklist', $blacklist);
|
||||||
|
|||||||
@@ -29,6 +29,25 @@ use App\Jobs\ProcessSendEveMailJob;
|
|||||||
|
|
||||||
class MoonsAdminController extends Controller
|
class MoonsAdminController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Variable for the class
|
||||||
|
*/
|
||||||
|
private $romans = [
|
||||||
|
'M' => 1000,
|
||||||
|
'CM' => 900,
|
||||||
|
'D' => 500,
|
||||||
|
'CD' => 400,
|
||||||
|
'C' => 100,
|
||||||
|
'XC' => 90,
|
||||||
|
'L' => 50,
|
||||||
|
'XL' => 40,
|
||||||
|
'X' => 10,
|
||||||
|
'IX' => 9,
|
||||||
|
'V' => 5,
|
||||||
|
'IV' => 4,
|
||||||
|
'I' => 1,
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the class
|
* Constructor for the class
|
||||||
*/
|
*/
|
||||||
@@ -499,4 +518,78 @@ class MoonsAdminController extends Controller
|
|||||||
//Redirect to the previous screen.
|
//Redirect to the previous screen.
|
||||||
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Rental updated.');
|
return redirect('/moons/admin/updatemoon')->with('success', 'Moon Rental updated.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function ImportMoonSurveyData(Request $request) {
|
||||||
|
//Declare variables
|
||||||
|
$added = 0;
|
||||||
|
$updated = 0;
|
||||||
|
$moon = null;
|
||||||
|
$newMoon = false;
|
||||||
|
$num = 0;
|
||||||
|
$planet = null;
|
||||||
|
$moonNumber = null;
|
||||||
|
|
||||||
|
foreach(explode("\n", $request->input('data')) as $row) {
|
||||||
|
$cols = explode("\t", $row);
|
||||||
|
dd($cols);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect('/admin/dashboard')->with('success', 'Import done: ' . $added . ' moons added ' . $updated . ' moons updated.');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function romanNumberToInteger($roman) {
|
||||||
|
$result = 0;
|
||||||
|
|
||||||
|
foreach($this->romans as $key => $value) {
|
||||||
|
while(strpos($roman, $key) === 0) {
|
||||||
|
$result += $value;
|
||||||
|
$roman = substr($roman, strlen($key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function integerToRomanNumber($number) {
|
||||||
|
$returnValue = '';
|
||||||
|
while($number > 0) {
|
||||||
|
foreach($this->romans as $roman => $int) {
|
||||||
|
if($number >= $int) {
|
||||||
|
$number -= $int;
|
||||||
|
$returnValue .= $roman;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function arrayToCsv(array $rows) {
|
||||||
|
//Declare needed variable as text null
|
||||||
|
$result = '';
|
||||||
|
|
||||||
|
//Open the temp file
|
||||||
|
$fp = fopen('php://temp', 'w');
|
||||||
|
|
||||||
|
//Process the file
|
||||||
|
foreach($rows as $fields) {
|
||||||
|
fputcsv($fp, $fields, ';', '"');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Go back to the beginning of the file
|
||||||
|
rewind($fp);
|
||||||
|
|
||||||
|
//Continue through the buffer until the end
|
||||||
|
while(($buffer = fgets($fp, 4096)) !== false) {
|
||||||
|
$result .= $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Close the temp file
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
//Return the result
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user