diff --git a/app/Http/Controllers/Blacklist/BlacklistController.php b/app/Http/Controllers/Blacklist/BlacklistController.php index eff6634a8..a207b15e4 100644 --- a/app/Http/Controllers/Blacklist/BlacklistController.php +++ b/app/Http/Controllers/Blacklist/BlacklistController.php @@ -57,23 +57,28 @@ class BlacklistController extends Controller if($count === 0) { //Get the character id from the universe end point $charId = $lookup->CharacterNameToId($request->name); - - //Insert the character into the blacklist table - BlacklistUser::insert([ - 'character_id' => $charId, - 'name' => $request->name, - 'reason' => $request->reason, - 'alts' => $request->alts, - 'lister_id' => auth()->user()->getId(), - 'lister_name' => auth()->user()->getName(), - ]); + + if($charId != null) { + //Insert the character into the blacklist table + BlacklistUser::insert([ + 'character_id' => $charId, + 'name' => $request->name, + 'reason' => $request->reason, + 'alts' => $request->alts, + '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 { //Return the view return view('blacklist.add')->with('error', 'Character is already on the black list.'); } //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) { @@ -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($blacklistCount > 0) { //Try to find the user in the blacklist - $blacklist = BlacklistUser::where([ - 'name' => $request->name, - ])->first(); + $blacklist = BlacklistUser::where(['name', 'like', $request->name])->get(); //Send the data to the view return view('blacklist.list')->with('blacklist', $blacklist) diff --git a/app/Library/Lookups/NewLookupHelper.php b/app/Library/Lookups/NewLookupHelper.php index b424427a0..29470dbe3 100644 --- a/app/Library/Lookups/NewLookupHelper.php +++ b/app/Library/Lookups/NewLookupHelper.php @@ -92,7 +92,7 @@ class NewLookupHelper { return $response->characters[0]->id; } else { - return -1; + return null; } } } @@ -147,7 +147,7 @@ class NewLookupHelper { return $response->corporations[0]->id; } else { - return -1; + return null; } } } @@ -200,7 +200,7 @@ class NewLookupHelper { return $response->alliances[0]->id; } else { - return -1; + return null; } } } @@ -359,7 +359,10 @@ class NewLookupHelper { } private function SaveCharacter($response, $charId) { + $esiHelper = new Esi; + $char = new CharacterLookup; + $char->character_id = $charId; if(isset($response->alliance_id)) { $char->alliance_id = $response->alliance_id; @@ -367,7 +370,7 @@ class NewLookupHelper { if(isset($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->corporation_id = $response->corporation_id; if(isset($response->description)) { @@ -518,6 +521,8 @@ class NewLookupHelper { } private function SaveCorporation($response, $corpId) { + $esiHelper = new Esi; + $corp = new CorporationLookup; $corp->corporation_id = $corpId; if(isset($response->alliance_id)) { @@ -526,7 +531,7 @@ class NewLookupHelper { $corp->ceo_id = $response->ceo_id; $corp->creator_id = $response->creator_id; if(isset($response->date_founded)) { - $corp->date_founded = $response->date_founded; + $corp->date_founded = $esiHelper->DecodeDate($response->date_founded); } if(isset($response->description)) { $corp->description = $response->description; @@ -706,11 +711,13 @@ class NewLookupHelper { } private function SaveAlliance($response, $allianceId) { + $esiHelper = new Esi; + $alliance = new AllianceLookup; $alliance->alliance_id = $allianceId; $alliance->creator_corporation_id = $response->creator_corporation_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)) { $alliance->executor_corporation_id = $response->executor_corporation_id; } diff --git a/database/migrations/2019_08_27_031538_new_lookup_tables.php b/database/migrations/2019_08_27_031538_new_lookup_tables.php index 34c2a2289..ecaadcbb0 100644 --- a/database/migrations/2019_08_27_031538_new_lookup_tables.php +++ b/database/migrations/2019_08_27_031538_new_lookup_tables.php @@ -16,7 +16,7 @@ class NewLookupTables extends Migration if(!Schema::hasTable('character_lookup')) { Schema::create('character_lookup', function (Blueprint $table) { $table->unsignedInteger('character_id'); - $table->unsignedInteger('alliance_id'); + $table->unsignedInteger('alliance_id')->nullable(); $table->unsignedInteger('ancestry_id')->nullable(); $table->string('birthday'); $table->unsignedInteger('bloodline_id'); @@ -47,7 +47,10 @@ class NewLookupTables extends Migration $table->decimal('tax_rate', 20, 2); $table->string('ticker'); $table->string('url')->nullable(); - $table->boolean('war_eligible'); + $table->enum('war_eligible', [ + 'Yes', + 'No', + ])->default('No'); }); } diff --git a/resources/views/blacklist/add.blade.php b/resources/views/blacklist/add.blade.php index cd5b346c0..8a6e4f0f8 100644 --- a/resources/views/blacklist/add.blade.php +++ b/resources/views/blacklist/add.blade.php @@ -1,16 +1,27 @@ @extends('layouts.b4') @section('content')
- {!! Form::open(['action' => 'Blacklist\BlacklistController@AddToBlacklist', 'method' => 'POST']) !!} -
- {{ Form::label('name', 'Character Name') }} - {{ Form::text('name', '', ['class' => 'form-control', 'placeholder' => 'CCP Antiquarian']) }} +
+
+

Add User to the Blacklist

+
+
+ {!! Form::open(['action' => 'Blacklist\BlacklistController@AddToBlacklist', 'method' => 'POST']) !!} +
+ {{ Form::label('name', 'Character Name') }} + {{ Form::text('name', '', ['class' => 'form-control', 'placeholder' => 'CCP Antiquarian']) }} +
+
+ {{ Form::label('reason', 'Reason') }} + {{ Form::textarea('reason', 'No reason given.', ['class' => 'form-control']) }} +
+
+ {{ Form::label('alts', 'Known Alts') }} + {{ Form::textarea('alts', '', ['class' => 'form-control']) }} +
+ {{ Form::submit('Submit', ['class' => 'btn btn-primary']) }} + {!! Form::close() !!} +
-
- {{ Form::label('reason', 'Reason') }} - {{ Form::textarea('reason', 'N/A', ['class' => 'form-control']) }} -
- {{ Form::submit('Submit', ['class' => 'btn btn-primary']) }} - {!! Form::close() !!}
@endsection \ No newline at end of file