diff --git a/app/Http/Controllers/Admin/Characters/CharacterController.php b/app/Http/Controllers/Admin/Characters/CharacterController.php index 68e2cfc033..d24674e5a9 100644 --- a/app/Http/Controllers/Admin/Characters/CharacterController.php +++ b/app/Http/Controllers/Admin/Characters/CharacterController.php @@ -205,7 +205,7 @@ public function getEditMyoStats($id) { public function postEditCharacterStats(Request $request, CharacterManager $service, $slug) { $request->validate(Character::$updateRules); $data = $request->only([ - 'character_category_id', 'number', 'slug', + 'character_category_id', 'number', 'slug', 'poucher_code', 'is_giftable', 'is_tradeable', 'is_sellable', 'sale_value', 'transferrable_at', ]); @@ -364,7 +364,7 @@ public function postEditMyoDescription(Request $request, CharacterManager $servi */ public function postCharacterSettings(Request $request, CharacterManager $service, $slug) { $data = $request->only([ - 'is_visible', + 'is_visible', 'dob', ]); $this->character = Character::where('slug', $slug)->first(); if (!$this->character) { diff --git a/app/Http/Controllers/BrowseController.php b/app/Http/Controllers/BrowseController.php index 46bd765f46..0cb87048b5 100644 --- a/app/Http/Controllers/BrowseController.php +++ b/app/Http/Controllers/BrowseController.php @@ -283,6 +283,9 @@ private function handleMasterlistSearch(Request $request, $query, $imageQuery, $ $query->where('characters.name', 'LIKE', '%'.$request->get('name').'%')->orWhere('characters.slug', 'LIKE', '%'.$request->get('name').'%'); }); } + if ($request->get('poucher_code')) { + $query->where('characters.poucher_code', 'LIKE', '%'.$request->get('poucher_code').'%'); + } if ($request->get('rarity_id')) { $query->where('rarity_id', $request->get('rarity_id')); } diff --git a/app/Models/Character/Character.php b/app/Models/Character/Character.php index 756a059c3c..6f67790a12 100644 --- a/app/Models/Character/Character.php +++ b/app/Models/Character/Character.php @@ -33,6 +33,7 @@ class Character extends Model { 'sale_value', 'transferrable_at', 'is_visible', 'is_gift_art_allowed', 'is_gift_writing_allowed', 'is_trading', 'sort', 'is_myo_slot', 'name', 'trade_id', 'owner_url', + 'dob', 'poucher_code', ]; /** @@ -49,6 +50,7 @@ class Character extends Model { */ protected $casts = [ 'transferrable_at' => 'datetime', + 'dob' => 'datetime', ]; /** diff --git a/app/Services/CharacterManager.php b/app/Services/CharacterManager.php index 3431a6b1af..78b7e1d1cf 100644 --- a/app/Services/CharacterManager.php +++ b/app/Services/CharacterManager.php @@ -1142,6 +1142,7 @@ public function updateCharacterStats($data, $character, $user) { $characterData['is_giftable'] = isset($data['is_giftable']); $characterData['sale_value'] = $data['sale_value'] ?? 0; $characterData['transferrable_at'] = $data['transferrable_at'] ?? null; + $characterData['poucher_code'] = $data['poucher_code'] ?? null; if ($character->is_myo_slot) { $characterData['name'] = (isset($data['name']) && $data['name']) ? $data['name'] : null; } @@ -1198,6 +1199,11 @@ public function updateCharacterStats($data, $character, $user) { $old['transferrable_at'] = $character->transferrable_at; $new['transferrable_at'] = $characterData['transferrable_at']; } + if ($characterData['poucher_code'] != $character->poucher_code) { + $result[] = 'poucher code'; + $old['poucher_code'] = $character->poucher_code; + $new['poucher_code'] = $characterData['poucher_code']; + } if (count($result)) { $character->update($characterData); @@ -1268,14 +1274,21 @@ public function updateCharacterSettings($data, $character, $user) { throw new \Exception('Failed to log admin action.'); } - $old = ['is_visible' => $character->is_visible]; + $old = [ + 'dob' => $character->dob, + 'is_visible' => $character->is_visible, + ]; + $character->dob = $data['dob'] ?? null; $character->is_visible = isset($data['is_visible']); $character->save(); // Add a log for the character // This logs all the updates made to the character - $this->createLog($user->id, null, null, null, $character->id, 'Character Visibility Updated', '', 'character', true, $old, ['is_visible' => $character->is_visible]); + $this->createLog($user->id, null, null, null, $character->id, 'Character Settings Updated', '', 'character', true, $old, [ + 'dob' => $character->dob, + 'is_visible' => $character->is_visible, + ]); return $this->commitReturn(true); } catch (\Exception $e) { diff --git a/database/migrations/2024_09_25_193855_add_fields_to_characters.php b/database/migrations/2024_09_25_193855_add_fields_to_characters.php new file mode 100644 index 0000000000..15bafc996e --- /dev/null +++ b/database/migrations/2024_09_25_193855_add_fields_to_characters.php @@ -0,0 +1,30 @@ +text('poucher_code')->nullable()->default(null)->after('name'); + $table->timestamp('dob')->nullable()->default(null); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('characters', function (Blueprint $table) { + // + }); + } +}; diff --git a/resources/views/browse/_masterlist_content.blade.php b/resources/views/browse/_masterlist_content.blade.php index e4c5b9ea8f..20dccb1048 100644 --- a/resources/views/browse/_masterlist_content.blade.php +++ b/resources/views/browse/_masterlist_content.blade.php @@ -5,6 +5,10 @@ {!! Form::label('name', 'Character Name/Code: ', ['class' => 'mr-2']) !!} {!! Form::text('name', Request::get('name'), ['class' => 'form-control']) !!} +