Skip to content

Commit

Permalink
Merge pull request #21 from preimpression/subtypesForProperSpecies
Browse files Browse the repository at this point in the history
Subtypes for proper species + Bugfixes
  • Loading branch information
itinerare authored Oct 14, 2020
2 parents a3e40e3 + 2694f23 commit 2b481cd
Show file tree
Hide file tree
Showing 16 changed files with 379 additions and 232 deletions.
55 changes: 38 additions & 17 deletions app/Http/Controllers/Admin/Characters/CharacterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getCreateCharacter()
'userOptions' => User::query()->orderBy('name')->pluck('name', 'id')->toArray(),
'rarities' => ['0' => 'Select Rarity'] + Rarity::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'specieses' => ['0' => 'Select Species'] + Species::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'subtypes' => ['0' => 'Select Subtype'] + Subtype::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'subtypes' => ['0' => 'Pick a Species First'],
'features' => Feature::orderBy('name')->pluck('name', 'id')->toArray(),
'isMyo' => false
]);
Expand All @@ -76,12 +76,33 @@ public function getCreateMyo()
'userOptions' => User::query()->orderBy('name')->pluck('name', 'id')->toArray(),
'rarities' => ['0' => 'Select Rarity'] + Rarity::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'specieses' => ['0' => 'Select Species'] + Species::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'subtypes' => ['0' => 'Select Subtype'] + Subtype::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'subtypes' => ['0' => 'Pick a Species First'],
'features' => Feature::orderBy('name')->pluck('name', 'id')->toArray(),
'isMyo' => true
]);
}






/**
* Shows the edit image subtype portion of the modal
*
* @param Request $request
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getCreateCharacterMyoSubtype(Request $request) {
$species = $request->input('species');
return view('admin.masterlist._create_character_subtype', [
'subtypes' => ['0' => 'Select Subtype'] + Subtype::where('species_id','=',$species)->orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'isMyo' => $request->input('myo')
]);
}




/**
* Creates a character.
*
Expand Down Expand Up @@ -111,7 +132,7 @@ public function postCreateCharacter(Request $request, CharacterManager $service)
}
return redirect()->back()->withInput();
}

/**
* Creates an MYO slot.
*
Expand Down Expand Up @@ -246,7 +267,7 @@ public function getEditCharacterDescription($slug)
{
$this->character = Character::where('slug', $slug)->first();
if(!$this->character) abort(404);

return view('character.admin._edit_description_modal', [
'character' => $this->character,
'isMyo' => false
Expand All @@ -263,7 +284,7 @@ public function getEditMyoDescription($id)
{
$this->character = Character::where('is_myo_slot', 1)->where('id', $id)->first();
if(!$this->character) abort(404);

return view('character.admin._edit_description_modal', [
'character' => $this->character,
'isMyo' => true
Expand Down Expand Up @@ -448,7 +469,7 @@ public function postMyoDelete(Request $request, CharacterManager $service, $id)
foreach($service->errors()->getMessages()['error'] as $error) flash($error)->error();
}
return redirect()->back();
}
}

/**
* Transfers a character.
Expand All @@ -462,7 +483,7 @@ public function postTransfer(Request $request, CharacterManager $service, $slug)
{
$this->character = Character::where('slug', $slug)->first();
if(!$this->character) abort(404);

if($service->adminTransfer($request->only(['recipient_id', 'recipient_alias', 'cooldown', 'reason']), $this->character, Auth::user())) {
flash('Character transferred successfully.')->success();
}
Expand All @@ -471,7 +492,7 @@ public function postTransfer(Request $request, CharacterManager $service, $slug)
}
return redirect()->back();
}

/**
* Transfers an MYO slot.
*
Expand All @@ -484,7 +505,7 @@ public function postMyoTransfer(Request $request, CharacterManager $service, $id
{
$this->character = Character::where('is_myo_slot', 1)->where('id', $id)->first();
if(!$this->character) abort(404);

if($service->adminTransfer($request->only(['recipient_id', 'cooldown', 'reason']), $this->character, Auth::user())) {
flash('Character transferred successfully.')->success();
}
Expand Down Expand Up @@ -519,7 +540,7 @@ public function getTransferQueue($type)
'tradeCount' => $openTransfersQueue ? Trade::where('status', 'Pending')->count() : 0
]);
}

/**
* Shows the character transfer action modal.
*
Expand All @@ -538,7 +559,7 @@ public function getTransferModal($id, $action)
'cooldown' => Settings::get('transfer_cooldown'),
]);
}

/**
* Acts on a transfer in the transfer queue.
*
Expand All @@ -552,7 +573,7 @@ public function postTransferQueue(Request $request, CharacterManager $service, $
if(!Auth::check()) abort(404);

$action = $request->get('action');

if($service->processTransferQueue($request->only(['action', 'cooldown', 'reason']) + ['transfer_id' => $id], Auth::user())) {
flash('Transfer ' . strtolower($action) . 'ed.')->success();
}
Expand All @@ -578,7 +599,7 @@ public function getTradeQueue($type)
else abort(404);

$openTransfersQueue = Settings::get('open_transfers_queue');

return view('admin.masterlist.character_trades', [
'trades' => $trades->orderBy('id', 'DESC')->paginate(20),
'tradesQueue' => Settings::get('open_transfers_queue'),
Expand All @@ -587,7 +608,7 @@ public function getTradeQueue($type)
'tradeCount' => $openTransfersQueue ? Trade::where('status', 'Pending')->count() : 0
]);
}

/**
* Shows the character trade action modal.
*
Expand All @@ -606,7 +627,7 @@ public function getTradeModal($id, $action)
'cooldown' => Settings::get('transfer_cooldown'),
]);
}

/**
* Acts on a trade in the trade queue.
*
Expand All @@ -631,7 +652,7 @@ public function postTradeQueue(Request $request, TradeManager $service, $id)
}
return redirect()->back();
}


/**
* Shows a list of all existing MYO slots.
Expand Down
42 changes: 37 additions & 5 deletions app/Http/Controllers/Admin/Characters/CharacterImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,27 @@ public function getNewImage($slug)
'character' => $this->character,
'rarities' => ['0' => 'Select Rarity'] + Rarity::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'specieses' => ['0' => 'Select Species'] + Species::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'subtypes' => ['0' => 'Select Subtype'] + Subtype::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'subtypes' => ['0' => 'Select Subtype'] + Subtype::where('species_id','=',$this->character->image->species_id)->orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'features' => Feature::orderBy('name')->pluck('name', 'id')->toArray(),
'isMyo' => false
]);
}

/**
* Shows the edit image subtype portion of the modal
*
* @param Request $request
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getNewImageSubtype(Request $request) {
$species = $request->input('species');
$id = $request->input('id');
return view('character.admin._upload_image_subtype', [
'subtypes' => ['0' => 'Select Subtype'] + Subtype::where('species_id','=',$species)->orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'subtype' => $id
]);
}

/**
* Creates a new image for a character.
*
Expand Down Expand Up @@ -83,11 +98,13 @@ public function postNewImage(Request $request, CharacterManager $service, $slug)
*/
public function getEditImageFeatures($id)
{
$image = CharacterImage::find($id);

return view('character.admin._edit_features_modal', [
'image' => CharacterImage::find($id),
'image' => $image,
'rarities' => ['0' => 'Select Rarity'] + Rarity::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'specieses' => ['0' => 'Select Species'] + Species::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'subtypes' => ['0' => 'Select Subtype'] + Subtype::orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'subtypes' => ['0' => 'Select Subtype'] + Subtype::where('species_id','=',$image->species_id)->orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
'features' => Feature::orderBy('name')->pluck('name', 'id')->toArray()
]);
}
Expand All @@ -114,6 +131,21 @@ public function postEditImageFeatures(Request $request, CharacterManager $servic
return redirect()->back()->withInput();
}

/**
* Shows the edit image subtype portion of the modal
*
* @param Request $request
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getEditImageSubtype(Request $request) {
$species = $request->input('species');
$id = $request->input('id');
return view('character.admin._edit_features_subtype', [
'image' => CharacterImage::find($id),
'subtypes' => ['0' => 'Select Subtype'] + Subtype::where('species_id','=',$species)->orderBy('sort', 'DESC')->pluck('name', 'id')->toArray(),
]);
}

/**
* Shows the edit image notes modal.
*
Expand Down Expand Up @@ -253,7 +285,7 @@ public function getImageActive($id)
'image' => CharacterImage::find($id),
]);
}


/**
* Sets an image to be the character's active image.
Expand Down Expand Up @@ -288,7 +320,7 @@ public function getImageDelete($id)
'image' => CharacterImage::find($id),
]);
}

/**
* Deletes an image.
*
Expand Down
Loading

0 comments on commit 2b481cd

Please sign in to comment.