updated default reason for blacklist.

This commit is contained in:
2019-12-04 20:36:30 -06:00
4 changed files with 56 additions and 32 deletions

View File

@@ -57,23 +57,28 @@ class BlacklistController extends Controller
if($count === 0) { if($count === 0) {
//Get the character id from the universe end point //Get the character id from the universe end point
$charId = $lookup->CharacterNameToId($request->name); $charId = $lookup->CharacterNameToId($request->name);
//Insert the character into the blacklist table if($charId != null) {
BlacklistUser::insert([ //Insert the character into the blacklist table
'character_id' => $charId, BlacklistUser::insert([
'name' => $request->name, 'character_id' => $charId,
'reason' => $request->reason, 'name' => $request->name,
'alts' => $request->alts, 'reason' => $request->reason,
'lister_id' => auth()->user()->getId(), 'alts' => $request->alts,
'lister_name' => auth()->user()->getName(), 'lister_id' => auth()->user()->getId(),
]); 'lister_name' => auth()->user()->getName(),
]);
} else {
//Redirect back to the view
return redirect('/blacklist/display/add')->with('error', $request->name . ' could not be added.');
}
} else { } else {
//Return the view //Return the view
return view('blacklist.add')->with('error', 'Character is already on the black list.'); return view('blacklist.add')->with('error', 'Character is already on the black list.');
} }
//Return the view //Return the view
return redirect('/blacklist/display')->with('success', 'Character added to the blacklist'); return redirect('/blacklist/display/add')->with('success', $request->name . ' added to the blacklist.');
} }
public function RemoveFromBlacklist(Request $request) { public function RemoveFromBlacklist(Request $request) {
@@ -118,9 +123,7 @@ class BlacklistController extends Controller
//If the count for the blacklist is greater than 0, then get the details, and send it to the view //If the count for the blacklist is greater than 0, then get the details, and send it to the view
if($blacklistCount > 0) { if($blacklistCount > 0) {
//Try to find the user in the blacklist //Try to find the user in the blacklist
$blacklist = BlacklistUser::where([ $blacklist = BlacklistUser::where(['name', 'like', $request->name])->get();
'name' => $request->name,
])->first();
//Send the data to the view //Send the data to the view
return view('blacklist.list')->with('blacklist', $blacklist) return view('blacklist.list')->with('blacklist', $blacklist)

View File

@@ -92,7 +92,7 @@ class NewLookupHelper {
return $response->characters[0]->id; return $response->characters[0]->id;
} else { } else {
return -1; return null;
} }
} }
} }
@@ -147,7 +147,7 @@ class NewLookupHelper {
return $response->corporations[0]->id; return $response->corporations[0]->id;
} else { } else {
return -1; return null;
} }
} }
} }
@@ -200,7 +200,7 @@ class NewLookupHelper {
return $response->alliances[0]->id; return $response->alliances[0]->id;
} else { } else {
return -1; return null;
} }
} }
} }
@@ -359,7 +359,10 @@ class NewLookupHelper {
} }
private function SaveCharacter($response, $charId) { private function SaveCharacter($response, $charId) {
$esiHelper = new Esi;
$char = new CharacterLookup; $char = new CharacterLookup;
$char->character_id = $charId; $char->character_id = $charId;
if(isset($response->alliance_id)) { if(isset($response->alliance_id)) {
$char->alliance_id = $response->alliance_id; $char->alliance_id = $response->alliance_id;
@@ -367,7 +370,7 @@ class NewLookupHelper {
if(isset($response->ancestry_id)) { if(isset($response->ancestry_id)) {
$char->ancestry_id = $response->ancestry_id; $char->ancestry_id = $response->ancestry_id;
} }
$char->birthday = $response->birthday; $char->birthday = $esiHelper->DecodeDate($response->birthday);
$char->bloodline_id = $response->bloodline_id; $char->bloodline_id = $response->bloodline_id;
$char->corporation_id = $response->corporation_id; $char->corporation_id = $response->corporation_id;
if(isset($response->description)) { if(isset($response->description)) {
@@ -518,6 +521,8 @@ class NewLookupHelper {
} }
private function SaveCorporation($response, $corpId) { private function SaveCorporation($response, $corpId) {
$esiHelper = new Esi;
$corp = new CorporationLookup; $corp = new CorporationLookup;
$corp->corporation_id = $corpId; $corp->corporation_id = $corpId;
if(isset($response->alliance_id)) { if(isset($response->alliance_id)) {
@@ -526,7 +531,7 @@ class NewLookupHelper {
$corp->ceo_id = $response->ceo_id; $corp->ceo_id = $response->ceo_id;
$corp->creator_id = $response->creator_id; $corp->creator_id = $response->creator_id;
if(isset($response->date_founded)) { if(isset($response->date_founded)) {
$corp->date_founded = $response->date_founded; $corp->date_founded = $esiHelper->DecodeDate($response->date_founded);
} }
if(isset($response->description)) { if(isset($response->description)) {
$corp->description = $response->description; $corp->description = $response->description;
@@ -706,11 +711,13 @@ class NewLookupHelper {
} }
private function SaveAlliance($response, $allianceId) { private function SaveAlliance($response, $allianceId) {
$esiHelper = new Esi;
$alliance = new AllianceLookup; $alliance = new AllianceLookup;
$alliance->alliance_id = $allianceId; $alliance->alliance_id = $allianceId;
$alliance->creator_corporation_id = $response->creator_corporation_id; $alliance->creator_corporation_id = $response->creator_corporation_id;
$alliance->creator_id = $response->creator_id; $alliance->creator_id = $response->creator_id;
$alliance->date_founded = $response->date_founded; $alliance->date_founded = $esiHelper->DecodeDate($response->date_founded);
if(isset($response->executor_corporation_id)) { if(isset($response->executor_corporation_id)) {
$alliance->executor_corporation_id = $response->executor_corporation_id; $alliance->executor_corporation_id = $response->executor_corporation_id;
} }

View File

@@ -16,7 +16,7 @@ class NewLookupTables extends Migration
if(!Schema::hasTable('character_lookup')) { if(!Schema::hasTable('character_lookup')) {
Schema::create('character_lookup', function (Blueprint $table) { Schema::create('character_lookup', function (Blueprint $table) {
$table->unsignedInteger('character_id'); $table->unsignedInteger('character_id');
$table->unsignedInteger('alliance_id'); $table->unsignedInteger('alliance_id')->nullable();
$table->unsignedInteger('ancestry_id')->nullable(); $table->unsignedInteger('ancestry_id')->nullable();
$table->string('birthday'); $table->string('birthday');
$table->unsignedInteger('bloodline_id'); $table->unsignedInteger('bloodline_id');
@@ -47,7 +47,10 @@ class NewLookupTables extends Migration
$table->decimal('tax_rate', 20, 2); $table->decimal('tax_rate', 20, 2);
$table->string('ticker'); $table->string('ticker');
$table->string('url')->nullable(); $table->string('url')->nullable();
$table->boolean('war_eligible'); $table->enum('war_eligible', [
'Yes',
'No',
])->default('No');
}); });
} }

View File

@@ -1,16 +1,27 @@
@extends('layouts.b4') @extends('layouts.b4')
@section('content') @section('content')
<div class="container"> <div class="container">
{!! Form::open(['action' => 'Blacklist\BlacklistController@AddToBlacklist', 'method' => 'POST']) !!} <div class="card">
<div class="form-group"> <div class="card-header">
{{ Form::label('name', 'Character Name') }} <h2>Add User to the Blacklist</h2>
{{ Form::text('name', '', ['class' => 'form-control', 'placeholder' => 'CCP Antiquarian']) }} </div>
<div class="card-body">
{!! Form::open(['action' => 'Blacklist\BlacklistController@AddToBlacklist', 'method' => 'POST']) !!}
<div class="form-group">
{{ Form::label('name', 'Character Name') }}
{{ Form::text('name', '', ['class' => 'form-control', 'placeholder' => 'CCP Antiquarian']) }}
</div>
<div class="form-group">
{{ Form::label('reason', 'Reason') }}
{{ Form::textarea('reason', 'No reason given.', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('alts', 'Known Alts') }}
{{ Form::textarea('alts', '', ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div>
</div> </div>
<div class="form-group">
{{ Form::label('reason', 'Reason') }}
{{ Form::textarea('reason', 'N/A', ['class' => 'form-control']) }}
</div>
{{ Form::submit('Submit', ['class' => 'btn btn-primary']) }}
{!! Form::close() !!}
</div> </div>
@endsection @endsection