From 26f4e3e0fb3c80810ab6d4161f60640addcdcdfc Mon Sep 17 00:00:00 2001 From: ScuffedNewt Date: Mon, 30 Oct 2023 15:06:15 +0000 Subject: [PATCH] run lint(s) --- .bladeformatterrc.json | 6 + .bladeignore | 1 + app/Console/Commands/AddSiteSettings.php | 64 +- app/Console/Commands/AddTextPages.php | 37 +- app/Console/Commands/CheckNews.php | 13 +- app/Console/Commands/CheckSales.php | 13 +- .../ClearDeletedCharacterAttachments.php | 17 +- app/Console/Commands/CopyDefaultImages.php | 22 +- app/Console/Commands/FixCharItemNotifs.php | 13 +- app/Console/Commands/MigrateAliases.php | 190 +- app/Console/Commands/SetupAdminUser.php | 121 +- .../Commands/UpdateExtensionTracker.php | 44 +- app/Console/Commands/UpdateLorekeeperV2.php | 33 +- app/Console/Kernel.php | 21 +- app/Events/CommentCreated.php | 10 +- app/Events/CommentDeleted.php | 10 +- app/Events/CommentUpdated.php | 10 +- app/Exceptions/Handler.php | 19 +- app/Facades/Notifications.php | 8 +- app/Facades/Settings.php | 8 +- app/Helpers/AssetHelpers.php | 292 +- app/Helpers/Helpers.php | 166 +- app/Helpers/Notifications.php | 23 +- app/Helpers/Settings.php | 16 +- .../Admin/Characters/CharacterController.php | 578 +- .../Characters/CharacterImageController.php | 324 +- .../Admin/Characters/GrantController.php | 52 +- .../Data/CharacterCategoryController.php | 107 +- .../Admin/Data/CriterionController.php | 417 +- .../Admin/Data/CurrencyController.php | 121 +- .../Admin/Data/FeatureController.php | 240 +- .../Admin/Data/GalleryController.php | 96 +- .../Controllers/Admin/Data/ItemController.php | 307 +- .../Admin/Data/LootTableController.php | 121 +- .../Admin/Data/PromptController.php | 213 +- .../Admin/Data/RarityController.php | 110 +- .../Controllers/Admin/Data/ShopController.php | 140 +- .../Admin/Data/SpeciesController.php | 217 +- .../Admin/Data/SublistController.php | 129 +- .../Controllers/Admin/DesignController.php | 99 +- app/Http/Controllers/Admin/FileController.php | 209 +- .../Controllers/Admin/GalleryController.php | 149 +- app/Http/Controllers/Admin/HomeController.php | 46 +- .../Admin/InvitationController.php | 49 +- app/Http/Controllers/Admin/NewsController.php | 95 +- app/Http/Controllers/Admin/PageController.php | 94 +- .../Controllers/Admin/RaffleController.php | 215 +- .../Controllers/Admin/ReportController.php | 69 +- .../Controllers/Admin/SalesController.php | 96 +- .../Controllers/Admin/SettingsController.php | 26 +- .../Admin/SubmissionController.php | 148 +- .../Admin/Users/GrantController.php | 96 +- .../Admin/Users/RankController.php | 101 +- .../Admin/Users/UserController.php | 221 +- .../Auth/ForgotPasswordController.php | 8 +- app/Http/Controllers/Auth/LoginController.php | 13 +- .../Controllers/Auth/RegisterController.php | 77 +- .../Auth/ResetPasswordController.php | 8 +- .../Auth/VerificationController.php | 8 +- app/Http/Controllers/BrowseController.php | 529 +- .../Characters/CharacterController.php | 456 +- .../Characters/DesignController.php | 321 +- .../Controllers/Characters/MyoController.php | 251 +- .../Comments/CommentController.php | 132 +- .../Comments/CommentControllerInterface.php | 7 +- app/Http/Controllers/Controller.php | 9 +- app/Http/Controllers/CriterionController.php | 95 +- app/Http/Controllers/GalleryController.php | 343 +- app/Http/Controllers/HomeController.php | 27 +- app/Http/Controllers/NewsController.php | 32 +- app/Http/Controllers/PageController.php | 30 +- app/Http/Controllers/PermalinkController.php | 68 +- app/Http/Controllers/PromptsController.php | 49 +- app/Http/Controllers/RaffleController.php | 46 +- app/Http/Controllers/SalesController.php | 30 +- app/Http/Controllers/ShopController.php | 104 +- .../Controllers/Users/AccountController.php | 214 +- app/Http/Controllers/Users/BankController.php | 39 +- .../Controllers/Users/BookmarkController.php | 95 +- .../Controllers/Users/CharacterController.php | 90 +- .../Controllers/Users/InventoryController.php | 280 +- .../Controllers/Users/ReportController.php | 71 +- .../Users/SubmissionController.php | 194 +- .../Controllers/Users/TradeController.php | 276 +- app/Http/Controllers/Users/UserController.php | 264 +- app/Http/Controllers/WorldController.php | 222 +- app/Http/Kernel.php | 27 +- app/Http/Middleware/Authenticate.php | 11 +- app/Http/Middleware/CheckAdmin.php | 11 +- app/Http/Middleware/CheckAlias.php | 18 +- .../Middleware/CheckForMaintenanceMode.php | 3 +- app/Http/Middleware/CheckPower.php | 12 +- app/Http/Middleware/CheckStaff.php | 11 +- app/Http/Middleware/EncryptCookies.php | 3 +- .../Middleware/RedirectIfAuthenticated.php | 12 +- app/Http/Middleware/TrimStrings.php | 3 +- app/Http/Middleware/TrustProxies.php | 5 +- app/Http/Middleware/VerifyCsrfToken.php | 3 +- app/Models/Character/Character.php | 300 +- app/Models/Character/CharacterBookmark.php | 36 +- app/Models/Character/CharacterCategory.php | 74 +- app/Models/Character/CharacterCurrency.php | 27 +- .../Character/CharacterDesignUpdate.php | 141 +- app/Models/Character/CharacterFeature.php | 23 +- app/Models/Character/CharacterImage.php | 116 +- .../Character/CharacterImageCreator.php | 47 +- app/Models/Character/CharacterItem.php | 44 +- app/Models/Character/CharacterLog.php | 31 +- app/Models/Character/CharacterProfile.php | 14 +- app/Models/Character/CharacterTransfer.php | 52 +- app/Models/Character/Sublist.php | 31 +- app/Models/Comment.php | 62 +- app/Models/Criteria/Criterion.php | 63 +- app/Models/Criteria/CriterionStep.php | 74 +- app/Models/Criteria/CriterionStepOption.php | 34 +- app/Models/Currency/Currency.php | 95 +- app/Models/Currency/CurrencyLog.php | 28 +- app/Models/Feature/Feature.php | 124 +- app/Models/Feature/FeatureCategory.php | 54 +- app/Models/Gallery/Gallery.php | 94 +- app/Models/Gallery/GalleryCharacter.php | 19 +- app/Models/Gallery/GalleryCollaborator.php | 34 +- app/Models/Gallery/GalleryCriterion.php | 44 +- app/Models/Gallery/GalleryFavorite.php | 17 +- app/Models/Gallery/GallerySubmission.php | 233 +- app/Models/Invitation.php | 18 +- app/Models/Item/Item.php | 209 +- app/Models/Item/ItemCategory.php | 52 +- app/Models/Item/ItemLog.php | 29 +- app/Models/Item/ItemTag.php | 68 +- app/Models/Loot/Loot.php | 33 +- app/Models/Loot/LootTable.php | 119 +- app/Models/Model.php | 3 +- app/Models/News.php | 50 +- app/Models/Notification.php | 153 +- app/Models/Prompt/Prompt.php | 132 +- app/Models/Prompt/PromptCategory.php | 54 +- app/Models/Prompt/PromptCriterion.php | 44 +- app/Models/Prompt/PromptReward.php | 29 +- app/Models/Raffle/Raffle.php | 51 +- app/Models/Raffle/RaffleGroup.php | 18 +- app/Models/Raffle/RaffleTicket.php | 43 +- app/Models/Rank/Rank.php | 88 +- app/Models/Rank/RankPower.php | 6 +- app/Models/Rarity.php | 67 +- app/Models/Report/Report.php | 81 +- app/Models/Sales/Sales.php | 41 +- app/Models/Sales/SalesCharacter.php | 53 +- app/Models/Shop/Shop.php | 61 +- app/Models/Shop/ShopLog.php | 41 +- app/Models/Shop/ShopStock.php | 23 +- app/Models/SitePage.php | 26 +- app/Models/Species/Species.php | 81 +- app/Models/Species/Subtype.php | 90 +- app/Models/Submission/Submission.php | 128 +- app/Models/Submission/SubmissionCharacter.php | 33 +- app/Models/Trade.php | 88 +- app/Models/User/User.php | 339 +- app/Models/User/UserAlias.php | 45 +- app/Models/User/UserCharacterLog.php | 30 +- app/Models/User/UserCurrency.php | 25 +- app/Models/User/UserItem.php | 92 +- app/Models/User/UserProfile.php | 21 +- app/Models/User/UserSettings.php | 27 +- app/Models/User/UserUpdateLog.php | 35 +- app/Policies/CommentPolicy.php | 52 +- app/Providers/AppServiceProvider.php | 12 +- app/Providers/AuthServiceProvider.php | 9 +- app/Providers/BroadcastServiceProvider.php | 10 +- app/Providers/CommentProvider.php | 49 +- app/Providers/EventServiceProvider.php | 14 +- app/Providers/NotificationsProvider.php | 18 +- app/Providers/RouteServiceProvider.php | 35 +- app/Providers/SettingsProvider.php | 18 +- app/Providers/Socialite/ToyhouseProvider.php | 15 +- app/Services/BookmarkManager.php | 121 +- app/Services/CharacterCategoryService.php | 135 +- app/Services/CharacterManager.php | 2863 +-- app/Services/CriterionService.php | 312 +- app/Services/CurrencyManager.php | 386 +- app/Services/CurrencyService.php | 247 +- app/Services/ExtensionService.php | 25 +- app/Services/FeatureService.php | 329 +- app/Services/FileManager.php | 152 +- app/Services/GalleryManager.php | 837 +- app/Services/GalleryService.php | 105 +- app/Services/InventoryManager.php | 596 +- app/Services/InvitationService.php | 58 +- app/Services/Item/BoxService.php | 130 +- app/Services/Item/SlotService.php | 139 +- app/Services/ItemService.php | 397 +- app/Services/LinkService.php | 99 +- app/Services/LootService.php | 171 +- app/Services/NewsService.php | 80 +- app/Services/PageService.php | 83 +- app/Services/PromptService.php | 316 +- app/Services/RaffleManager.php | 170 +- app/Services/RaffleService.php | 104 +- app/Services/RankService.php | 125 +- app/Services/RarityService.php | 148 +- app/Services/ReportManager.php | 129 +- app/Services/SalesService.php | 244 +- app/Services/Service.php | 252 +- app/Services/ShopManager.php | 145 +- app/Services/ShopService.php | 177 +- app/Services/SpeciesService.php | 273 +- app/Services/SublistService.php | 96 +- app/Services/SubmissionManager.php | 585 +- app/Services/TradeManager.php | 702 +- app/Services/UserService.php | 234 +- app/Traits/Commentable.php | 44 +- app/Traits/Commenter.php | 13 +- composer.json | 35 +- config/app.php | 78 +- config/auth.php | 14 +- config/broadcasting.php | 12 +- config/cache.php | 20 +- config/database.php | 76 +- config/filesystems.php | 12 +- config/hashing.php | 4 +- config/logging.php | 38 +- config/lorekeeper/admin_sidebar.php | 100 +- config/lorekeeper/comments.php | 12 +- config/lorekeeper/extension_tracker.php | 6 +- config/lorekeeper/extensions.php | 10 +- config/lorekeeper/image_files.php | 40 +- config/lorekeeper/item_tags.php | 14 +- config/lorekeeper/notifications.php | 234 +- config/lorekeeper/powers.php | 43 +- config/lorekeeper/settings.php | 20 +- config/lorekeeper/text_pages.php | 9 +- config/mail.php | 2 +- config/queue.php | 28 +- database/factories/UserFactory.php | 10 +- .../2014_10_12_000000_create_users_table.php | 26 +- ...12_100000_create_password_resets_table.php | 17 +- ...018_06_30_113500_create_comments_table.php | 27 +- .../2019_02_27_075638_create_game_tables.php | 68 +- .../2019_04_07_130129_add_site_settings.php | 25 +- ...019_04_09_090831_create_user_log_table.php | 25 +- ...19_04_09_095513_create_currency_tables.php | 29 +- ...019_04_12_123405_fix_data_descriptions.php | 159 +- ...2019_04_13_094613_add_owned_currencies.php | 17 +- ...14_120732_add_image_to_item_categories.php | 17 +- ...4_14_121447_add_transfer_flag_to_items.php | 17 +- .../2019_04_15_122508_add_prompts_table.php | 23 +- ...6_062617_add_parsed_text_to_site_pages.php | 17 +- .../2019_04_16_080112_add_invitation_keys.php | 19 +- ...2019_04_19_125212_fix_inventory_tables.php | 26 +- .../2019_04_20_140827_fix_user_item_log.php | 21 +- ...4_29_080228_fix_inventory_tables_again.php | 17 +- ...019_04_30_070721_add_notification_data.php | 17 +- .../migrations/2019_05_04_091240_add_news.php | 17 +- ...9_05_11_045038_update_character_tables.php | 34 +- ..._05_12_064538_add_species_id_to_images.php | 21 +- ...9_05_12_100722_make_features_nonunique.php | 19 +- ...54413_make_character_image_id_nullable.php | 23 +- .../2019_05_20_075936_add_character_sort.php | 17 +- ...1701_add_changed_data_to_character_log.php | 17 +- ...83954_create_character_transfer_tables.php | 17 +- .../2019_07_09_063021_create_raffles.php | 17 +- .../2019_07_13_095608_create_loot_tables.php | 23 +- ..._07_13_101743_create_prompt_categories.php | 21 +- .../2019_07_15_090200_add_prompt_rewards.php | 19 +- ...19_07_21_161720_add_prompt_submissions.php | 23 +- ..._add_submission_count_to_user_settings.php | 17 +- ...451_make_submission_prompt_id_nullable.php | 17 +- .../2019_08_10_120818_add_myo_slots.php | 25 +- .../2019_08_24_101751_add_design_updates.php | 45 +- ...1303_drop_images_character_foreign_key.php | 20 +- ...400_drop_character_images_foreign_keys.php | 21 +- ...923_add_submitted_at_to_design_updates.php | 17 +- ...7_110010_rename_design_approval_status.php | 15 +- .../2019_09_28_040911_create_shops.php | 25 +- ..._10_02_085738_add_shop_purchase_limits.php | 17 +- .../migrations/2019_10_12_095632_add_bans.php | 17 +- .../2019_10_21_081343_add_secure_trades.php | 22 +- ...062623_modify_trade_confirmation_flags.php | 17 +- ...19_12_02_090542_add_staff_id_to_trades.php | 17 +- .../2019_12_23_062730_add_item_tags.php | 21 +- ...3_135512_make_prompt_category_nullable.php | 18 +- .../2020_03_07_065050_add_bookmarks.php | 17 +- ...241_make_character_log_sender_nullable.php | 17 +- .../2020_03_14_124534_add_subtypes.php | 33 +- ...020_03_23_075539_add_images_to_prompts.php | 17 +- ...0_03_27_113928_add_subtype_to_features.php | 21 +- ...020_04_25_114747_drop_log_foreign_keys.php | 21 +- ...05_02_152118_drop_character_myo_counts.php | 26 +- ...204920_change_user_items_count_default.php | 15 +- ...163751_add_holding_count_to_user_items.php | 17 +- ..._23_112548_change_item_tracking_system.php | 17 +- ..._124250_add_parsed_submission_comments.php | 17 +- ...2020_06_06_194000_add_submission_count.php | 17 +- ...06_12_155213_add_character_items_table.php | 19 +- ...cter_transfer_perms_to_item_categories.php | 17 +- ...15_205604_fix_character_item_log_table.php | 18 +- ..._recipient_type_to_character_items_log.php | 17 +- ...6_adjust_item_logs_for_character_items.php | 19 +- ...tems_log_sender_recipient_default_null.php | 19 +- ...2020_06_19_142842_item_entry_extension.php | 17 +- .../2020_07_27_153640_user_icon_expansion.php | 19 +- ...7_31_185640_add_type_to_design_updates.php | 17 +- ..._31_193235_set_design_update_type_null.php | 15 +- ...dd_stack_name_to_character_items_table.php | 17 +- ...8_10_211220_raise_items_log_char_limit.php | 17 +- ..._13_173324_add_votes_to_design_updates.php | 17 +- ..._add_fullsize_hash_to_character_images.php | 17 +- .../2020_08_27_181445_char-link-addon.php | 17 +- .../2020_09_01_122320_add_sales.php | 17 +- .../2020_09_11_181218_add_is_featured.php | 19 +- .../2020_09_12_181218_add_rank_icon.php | 17 +- ..._add_toggle_for_comments_on_site_pages.php | 17 +- .../2020_09_16_190405_make_gallery_tables.php | 22 +- .../2020_09_17_185436_fix_gallery_tables.php | 17 +- .../2020_09_18_194615_re_add_gallery_sort.php | 17 +- ...rejected_status_to_gallery_submissions.php | 15 +- ...23205_add_title_to_gallery_submissions.php | 17 +- .../2020_09_21_205840_transfer_reason.php | 17 +- ...3_set_gallery_submission_hash_nullable.php | 17 +- ..._26_140543_add_gallery_favorites_table.php | 17 +- ..._staff_comments_to_gallery_submissions.php | 17 +- ...d_valued_status_to_gallery_submissions.php | 17 +- ...pe_to_gallery_submission_collaborators.php | 17 +- ...020_10_03_211413_add_prefix_to_prompts.php | 17 +- ...ise_currencies_log_log_character_limit.php | 17 +- .../2020_10_08_081102_add_sub_masterlist.php | 21 +- .../2020_10_15_143857_add_user_reports.php | 19 +- ...020_10_15_185536_add_bug_report_option.php | 17 +- ...2020_10_19_144506_add_type_to_comments.php | 19 +- ...content_warning_to_gallery_submissions.php | 17 +- ..._add_gift_writing_status_to_characters.php | 17 +- ...2_204925_add_delayed_comments_to_sales.php | 17 +- ...dd_user_id_to_character_image_creators.php | 17 +- ...2020_11_13_180553_create_aliases_table.php | 17 +- ...13_184820_add_has_alias_to_users_table.php | 17 +- ...020_11_17_001602_add_url_to_characters.php | 17 +- ...11_17_181454_add_url_to_character_logs.php | 17 +- ...1215_add_visibility_toggles_to_prompts.php | 17 +- ...11_23_152732_add_site_extensions_table.php | 17 +- ...20_11_25_192234_add_artist_id_to_items.php | 17 +- ...6_060832_make_submissions_url_nullable.php | 16 +- ..._04_181214_add_scheduling_to_galleries.php | 17 +- ...2020_12_05_165316_index_gallery_tables.php | 17 +- ...021_01_08_230640_add_released_to_items.php | 13 +- ..._012947_add_select_prompt_to_galleries.php | 13 +- ...1530_change_character_value_to_decimal.php | 13 +- ...172111_add_item_category_info_to_loots.php | 13 +- ...1_04_22_230225_create_sales_characters.php | 13 +- .../2021_04_29_175640_add_user_birthday.php | 21 +- ..._19_123518_change_birthday_column_type.php | 17 +- .../2022_10_03_165700_create_calculators.php | 23 +- ...09_203539_add_calculator_relationships.php | 15 +- ..._11_21_170405_add_rounding_to_criteria.php | 4 - database/seeds/DatabaseSeeder.php | 19 +- package-lock.json | 18449 ++++++++++++++++ package.json | 34 +- pint.json | 188 + public/index.php | 4 +- resources/lang/en/auth.php | 2 +- resources/lang/en/pagination.php | 2 +- resources/lang/en/passwords.php | 8 +- resources/lang/en/validation.php | 156 +- .../galleries/_archive_submission.blade.php | 13 +- .../views/galleries/_character.blade.php | 4 +- .../galleries/_character_select.blade.php | 8 +- .../_character_select_entry.blade.php | 8 +- .../galleries/_character_select_js.blade.php | 4 +- .../galleries/_queue_submission.blade.php | 38 +- resources/views/galleries/_sidebar.blade.php | 14 +- .../galleries/_submission_favorites.blade.php | 12 +- .../galleries/_submission_totals.blade.php | 30 +- resources/views/galleries/_thumb.blade.php | 69 +- .../create_edit_submission.blade.php | 556 +- resources/views/galleries/gallery.blade.php | 107 +- resources/views/galleries/index.blade.php | 120 +- resources/views/galleries/layout.blade.php | 6 +- .../views/galleries/submission.blade.php | 364 +- .../views/galleries/submission_log.blade.php | 277 +- .../views/galleries/submissions.blade.php | 70 +- resources/views/home/_character.blade.php | 4 +- .../views/home/_inventory_stack.blade.php | 90 +- resources/views/home/_prompt.blade.php | 10 +- resources/views/home/_report.blade.php | 14 +- .../views/home/_report_content.blade.php | 62 +- resources/views/home/_sidebar.blade.php | 2 +- resources/views/home/_submission.blade.php | 4 +- .../views/home/_submission_content.blade.php | 186 +- resources/views/home/_transfer.blade.php | 32 +- resources/views/home/account_search.blade.php | 170 +- resources/views/home/bank.blade.php | 73 +- .../views/home/bug_report_index.blade.php | 67 +- .../views/home/character_transfers.blade.php | 46 +- resources/views/home/characters.blade.php | 58 +- resources/views/home/create_report.blade.php | 80 +- .../views/home/create_submission.blade.php | 296 +- resources/views/home/home.blade.php | 1 + resources/views/home/inventory.blade.php | 95 +- resources/views/home/layout.blade.php | 8 +- resources/views/home/myos.blade.php | 36 +- resources/views/home/report.blade.php | 21 +- resources/views/home/reports.blade.php | 66 +- resources/views/home/submission.blade.php | 9 +- resources/views/home/submissions.blade.php | 116 +- .../views/home/submissions_closed.blade.php | 80 +- resources/views/welcome.blade.php | 6 +- routes/lorekeeper/admin.php | 122 +- routes/lorekeeper/browse.php | 39 +- routes/lorekeeper/members.php | 36 +- routes/web.php | 20 +- server.php | 4 +- tests/CreatesApplication.php | 6 +- tests/Feature/ExampleTest.php | 9 +- tests/TestCase.php | 3 +- tests/Unit/ExampleTest.php | 9 +- yarn.lock | 11388 +++++----- 415 files changed, 41448 insertions(+), 21954 deletions(-) create mode 100644 .bladeformatterrc.json create mode 100644 .bladeignore create mode 100644 package-lock.json create mode 100644 pint.json diff --git a/.bladeformatterrc.json b/.bladeformatterrc.json new file mode 100644 index 0000000000..7d72ac635b --- /dev/null +++ b/.bladeformatterrc.json @@ -0,0 +1,6 @@ +{ + "indentSize": 4, + "wrapLineLength": 250, + "endWithNewLine": true, + "useTabs": false +} diff --git a/.bladeignore b/.bladeignore new file mode 100644 index 0000000000..140fada73f --- /dev/null +++ b/.bladeignore @@ -0,0 +1 @@ +vendor/* diff --git a/app/Console/Commands/AddSiteSettings.php b/app/Console/Commands/AddSiteSettings.php index 17f1ad20ce..d750905bbf 100644 --- a/app/Console/Commands/AddSiteSettings.php +++ b/app/Console/Commands/AddSiteSettings.php @@ -2,12 +2,10 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; - use DB; +use Illuminate\Console\Command; -class AddSiteSettings extends Command -{ +class AddSiteSettings extends Command { /** * The name and signature of the console command. * @@ -24,45 +22,17 @@ class AddSiteSettings extends Command /** * Create a new command instance. - * - * @return void */ - public function __construct() - { + public function __construct() { parent::__construct(); } - /** - * Add a site setting. - * - * Example usage: - * $this->addSiteSetting("site_setting_key", 1, "0: does nothing. 1: does something."); - * - * @param string $key - * @param int $value - * @param string $description - */ - private function addSiteSetting($key, $value, $description) { - if(!DB::table('site_settings')->where('key', $key)->exists()) { - DB::table('site_settings')->insert([ - [ - 'key' => $key, - 'value' => $value, - 'description' => $description, - ], - ]); - $this->info( "Added: ".$key." / Default: ".$value); - } - else $this->line("Skipped: ".$key); - } - /** * Execute the console command. * * @return mixed */ - public function handle() - { + public function handle() { $this->info('*********************'); $this->info('* ADD SITE SETTINGS *'); $this->info('*********************'."\n"); @@ -96,12 +66,36 @@ public function handle() $this->addSiteSetting('admin_user', 1, 'ID of the site\'s admin user.'); $this->addSiteSetting('gallery_submissions_open', 1, '0: Gallery submissions closed, 1: Gallery submissions open.'); - + $this->addSiteSetting('gallery_rewards_divided', 1, '0: Gallery criteria rewards will be rewarded to each collaborator, 1: Gallery criteria rewards will be divided between collaborators.'); $this->addSiteSetting('gallery_submissions_require_approval', 1, '0: Gallery submissions do not require approval, 1: Gallery submissions require approval.'); $this->line("\nSite settings up to date!"); + } + /** + * Add a site setting. + * + * Example usage: + * $this->addSiteSetting("site_setting_key", 1, "0: does nothing. 1: does something."); + * + * @param string $key + * @param int $value + * @param string $description + */ + private function addSiteSetting($key, $value, $description) { + if (!DB::table('site_settings')->where('key', $key)->exists()) { + DB::table('site_settings')->insert([ + [ + 'key' => $key, + 'value' => $value, + 'description' => $description, + ], + ]); + $this->info('Added: '.$key.' / Default: '.$value); + } else { + $this->line('Skipped: '.$key); + } } } diff --git a/app/Console/Commands/AddTextPages.php b/app/Console/Commands/AddTextPages.php index 7446f3f6a8..a0d6959022 100644 --- a/app/Console/Commands/AddTextPages.php +++ b/app/Console/Commands/AddTextPages.php @@ -2,13 +2,12 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; +use Carbon\Carbon; use Config; use DB; -use Carbon\Carbon; +use Illuminate\Console\Command; -class AddTextPages extends Command -{ +class AddTextPages extends Command { /** * The name and signature of the console command. * @@ -25,11 +24,8 @@ class AddTextPages extends Command /** * Create a new command instance. - * - * @return void */ - public function __construct() - { + public function __construct() { parent::__construct(); } @@ -38,34 +34,33 @@ public function __construct() * * @return mixed */ - public function handle() - { + public function handle() { // $pages = Config::get('lorekeeper.text_pages'); - $this->info('******************'); $this->info('* ADD SITE PAGES *'); $this->info('******************'."\n"); $this->line("Adding site pages...existing entries will be skipped.\n"); - foreach($pages as $key => $page) { - if(!DB::table('site_pages')->where('key', $key)->exists()) { + foreach ($pages as $key => $page) { + if (!DB::table('site_pages')->where('key', $key)->exists()) { DB::table('site_pages')->insert([ [ - 'key' => $key, - 'title' => $page['title'], - 'text' => $page['text'], + 'key' => $key, + 'title' => $page['title'], + 'text' => $page['text'], 'parsed_text' => $page['text'], - 'created_at' => Carbon::now(), - 'updated_at' => Carbon::now(), - ] + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ], ]); - $this->info("Added: ".$page['title']); + $this->info('Added: '.$page['title']); + } else { + $this->line('Skipped: '.$page['title']); } - else $this->line("Skipped: ".$page['title']); } } } diff --git a/app/Console/Commands/CheckNews.php b/app/Console/Commands/CheckNews.php index f9f63cd7d9..ee1456b626 100644 --- a/app/Console/Commands/CheckNews.php +++ b/app/Console/Commands/CheckNews.php @@ -2,11 +2,10 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; use App\Services\NewsService; +use Illuminate\Console\Command; -class CheckNews extends Command -{ +class CheckNews extends Command { /** * The name and signature of the console command. * @@ -23,11 +22,8 @@ class CheckNews extends Command /** * Create a new command instance. - * - * @return void */ - public function __construct() - { + public function __construct() { parent::__construct(); } @@ -36,8 +32,7 @@ public function __construct() * * @return mixed */ - public function handle() - { + public function handle() { // (new NewsService)->updateQueue(); } diff --git a/app/Console/Commands/CheckSales.php b/app/Console/Commands/CheckSales.php index a2e8176ca8..4d015699e3 100644 --- a/app/Console/Commands/CheckSales.php +++ b/app/Console/Commands/CheckSales.php @@ -2,11 +2,10 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; use App\Services\SalesService; +use Illuminate\Console\Command; -class CheckSales extends Command -{ +class CheckSales extends Command { /** * The name and signature of the console command. * @@ -23,11 +22,8 @@ class CheckSales extends Command /** * Create a new command instance. - * - * @return void */ - public function __construct() - { + public function __construct() { parent::__construct(); } @@ -36,8 +32,7 @@ public function __construct() * * @return mixed */ - public function handle() - { + public function handle() { // (new SalesService)->updateQueue(); } diff --git a/app/Console/Commands/ClearDeletedCharacterAttachments.php b/app/Console/Commands/ClearDeletedCharacterAttachments.php index daeb1f98d9..af57bf6df3 100644 --- a/app/Console/Commands/ClearDeletedCharacterAttachments.php +++ b/app/Console/Commands/ClearDeletedCharacterAttachments.php @@ -2,17 +2,14 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; - -use DB; - use App\Models\Character\Character; use App\Models\Character\CharacterCurrency; use App\Models\Character\CharacterFeature; use App\Models\Character\CharacterImage; +use DB; +use Illuminate\Console\Command; -class ClearDeletedCharacterAttachments extends Command -{ +class ClearDeletedCharacterAttachments extends Command { /** * The name and signature of the console command. * @@ -29,11 +26,8 @@ class ClearDeletedCharacterAttachments extends Command /** * Create a new command instance. - * - * @return void */ - public function __construct() - { + public function __construct() { parent::__construct(); } @@ -42,8 +36,7 @@ public function __construct() * * @return mixed */ - public function handle() - { + public function handle() { // Get deleted character IDs $deletedCharacterIds = DB::table('characters')->whereNotNull('deleted_at')->pluck('id'); diff --git a/app/Console/Commands/CopyDefaultImages.php b/app/Console/Commands/CopyDefaultImages.php index 78cb8f798c..b13700f9af 100644 --- a/app/Console/Commands/CopyDefaultImages.php +++ b/app/Console/Commands/CopyDefaultImages.php @@ -5,8 +5,7 @@ use Config; use Illuminate\Console\Command; -class CopyDefaultImages extends Command -{ +class CopyDefaultImages extends Command { /** * The name and signature of the console command. * @@ -23,11 +22,8 @@ class CopyDefaultImages extends Command /** * Create a new command instance. - * - * @return void */ - public function __construct() - { + public function __construct() { parent::__construct(); } @@ -36,8 +32,7 @@ public function __construct() * * @return mixed */ - public function handle() - { + public function handle() { // $this->info('***********************'); $this->info('* COPY DEFAULT IMAGES *'); @@ -45,13 +40,12 @@ public function handle() $images = Config::get('lorekeeper.image_files'); - $sourceDir = base_path() . '/data/images/'; - $destDir = public_path() . '/images/'; + $sourceDir = base_path().'/data/images/'; + $destDir = public_path().'/images/'; - foreach($images as $image) - { - $this->line("Copying image: ".$image['filename'] . "\n"); - copy($sourceDir . $image['filename'], $destDir . $image['filename']); + foreach ($images as $image) { + $this->line('Copying image: '.$image['filename']."\n"); + copy($sourceDir.$image['filename'], $destDir.$image['filename']); } $this->line('Done!'); } diff --git a/app/Console/Commands/FixCharItemNotifs.php b/app/Console/Commands/FixCharItemNotifs.php index f66d7e8703..0a149f36b9 100644 --- a/app/Console/Commands/FixCharItemNotifs.php +++ b/app/Console/Commands/FixCharItemNotifs.php @@ -2,11 +2,10 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; use App\Services\ExtensionService; +use Illuminate\Console\Command; -class FixCharItemNotifs extends Command -{ +class FixCharItemNotifs extends Command { /** * The name and signature of the console command. * @@ -23,11 +22,8 @@ class FixCharItemNotifs extends Command /** * Create a new command instance. - * - * @return void */ - public function __construct() - { + public function __construct() { parent::__construct(); } @@ -36,8 +32,7 @@ public function __construct() * * @return mixed */ - public function handle() - { + public function handle() { // (new ExtensionService)->updateNotifications(39, 501); (new ExtensionService)->updateNotifications(40, 502); diff --git a/app/Console/Commands/MigrateAliases.php b/app/Console/Commands/MigrateAliases.php index 9d6fa89033..1e41bf9c80 100644 --- a/app/Console/Commands/MigrateAliases.php +++ b/app/Console/Commands/MigrateAliases.php @@ -2,22 +2,19 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; - -use DB; -use Illuminate\Support\Facades\Schema; -use Illuminate\Database\Schema\Blueprint; - -use App\Models\User\User; -use App\Models\User\UserAlias; use App\Models\Character\Character; use App\Models\Character\CharacterImageCreator; use App\Models\Character\CharacterLog; -use App\Models\User\UserCharacterLog; use App\Models\Item\Item; +use App\Models\User\User; +use App\Models\User\UserAlias; +use App\Models\User\UserCharacterLog; +use DB; +use Illuminate\Console\Command; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; -class MigrateAliases extends Command -{ +class MigrateAliases extends Command { /** * The name and signature of the console command. * @@ -34,11 +31,8 @@ class MigrateAliases extends Command /** * Create a new command instance. - * - * @return void */ - public function __construct() - { + public function __construct() { parent::__construct(); } @@ -47,200 +41,205 @@ public function __construct() * * @return mixed */ - public function handle() - { + public function handle() { $this->info('*****************************'); $this->info('* MIGRATE ALIAS INFORMATION *'); $this->info('*****************************'."\n"); $this->line("Migrating aliases...\n"); - /** MOVE USER ALIASES */ - if(Schema::hasColumn('users', 'alias')) { + /* MOVE USER ALIASES */ + if (Schema::hasColumn('users', 'alias')) { // Get users with a set alias $aliasUsers = User::whereNotNull('alias')->get(); - if($aliasUsers->count()) { - foreach($aliasUsers as $user) { - if(!DB::table('user_aliases')->where('user_id', $user->id)->where('site', 'deviantart')->where('alias', $user->alias)->exists()) { + if ($aliasUsers->count()) { + foreach ($aliasUsers as $user) { + if (!DB::table('user_aliases')->where('user_id', $user->id)->where('site', 'deviantart')->where('alias', $user->alias)->exists()) { // Create a new row for the user's current dA alias DB::table('user_aliases')->insert([ [ - 'user_id' => $user->id, - 'site' => 'deviantart', - 'alias' => $user->alias, - 'is_visible' => 1, + 'user_id' => $user->id, + 'site' => 'deviantart', + 'alias' => $user->alias, + 'is_visible' => 1, 'is_primary_alias' => 1, - ] + ], ]); // Clear the user's alias in the users table and set the has_alias bool in its place $user->update([ - 'alias' => null, - 'has_alias' => 1 + 'alias' => null, + 'has_alias' => 1, ]); } } - $this->info("Migrated: User aliases"); + $this->info('Migrated: User aliases'); + } else { + $this->line('Skipped: User aliases (nothing to migrate)'); } - else $this->line("Skipped: User aliases (nothing to migrate)"); + } else { + $this->line('Skipped: User aliases (column no longer exists)'); } - else $this->line("Skipped: User aliases (column no longer exists)"); $daAliases = UserAlias::where('site', 'dA')->get(); - if($daAliases->count()) { + if ($daAliases->count()) { $this->line('Updating '.$daAliases->count().' deviantArt aliases...'); - foreach($daAliases as $alias) { + foreach ($daAliases as $alias) { $alias->site = 'deviantart'; $alias->save(); } $this->info('deviantArt aliases updated!'); + } else { + $this->line('No deviantArt aliases to update!'); } - else $this->line('No deviantArt aliases to update!'); - /** MOVE CHARACTER OWNER ALIASES */ - if(Schema::hasColumn('characters', 'owner_alias')) { + /* MOVE CHARACTER OWNER ALIASES */ + if (Schema::hasColumn('characters', 'owner_alias')) { // This and the following section operate on the assumption that all aliases to this point have been dA accounts // Get characters with an owner identified by alias $aliasCharacters = Character::whereNotNull('owner_alias')->get(); - if($aliasCharacters->count()) { - foreach($aliasCharacters as $character) { + if ($aliasCharacters->count()) { + foreach ($aliasCharacters as $character) { // Just in case, check to update character ownership $userAlias = UserAlias::where('site', 'deviantart')->where('alias', $character->owner_alias)->first(); - if($userAlias) { + if ($userAlias) { $character->update(['owner_alias' => null, 'user_id' => $userAlias->user_id]); - } - elseif(!$userAlias) { + } elseif (!$userAlias) { $alias = $character->owner_alias; $character->update(['owner_alias' => null, 'owner_url' => 'https://deviantart.com/'.$alias]); } } - $this->info("Migrated: Character owner aliases"); + $this->info('Migrated: Character owner aliases'); + } else { + $this->line('Skipped: Character owner aliases (nothing to migrate)'); } - else $this->line("Skipped: Character owner aliases (nothing to migrate)"); + } else { + $this->line('Skipped: Character owner aliases (column no longer exists)'); } - else $this->line("Skipped: Character owner aliases (column no longer exists)"); - if(Schema::hasColumn('character_image_creators', 'alias')) { + if (Schema::hasColumn('character_image_creators', 'alias')) { /** MOVE CHARACTER IMAGE CREATOR ALIASES */ // Get character image creators with a set alias $aliasImageCreators = CharacterImageCreator::whereNotNull('alias')->get(); - if($aliasImageCreators->count()){ - foreach($aliasImageCreators as $creator) { + if ($aliasImageCreators->count()) { + foreach ($aliasImageCreators as $creator) { $userAlias = UserAlias::where('site', 'deviantart')->where('alias', $creator->alias)->first(); - if($userAlias) { + if ($userAlias) { $creator->update(['alias' => null, 'user_id' => $userAlias->user_id]); - } - elseif(!$userAlias) { + } elseif (!$userAlias) { $alias = $creator->alias; $creator->update(['alias' => null, 'url' => 'https://deviantart.com/'.$alias]); } } - $this->info("Migrated: Character image creator aliases"); + $this->info('Migrated: Character image creator aliases'); + } else { + $this->line('Skipped: Character image creator aliases (nothing to migrate)'); } - else $this->line("Skipped: Character image creator aliases (nothing to migrate)"); + } else { + $this->line('Skipped: Character image creator aliases (column no longer exists)'); } - else $this->line("Skipped: Character image creator aliases (column no longer exists)"); - /** MOVE CHARACTER LOG ALIASES */ + /* MOVE CHARACTER LOG ALIASES */ - if(Schema::hasColumn('character_log', 'recipient_alias') || Schema::hasColumn('character_log', 'sender_alias')) { + if (Schema::hasColumn('character_log', 'recipient_alias') || Schema::hasColumn('character_log', 'sender_alias')) { // Get character logs with a set recipient alias $aliasCharacterLogs = CharacterLog::whereNotNull('recipient_alias')->get(); $aliasCharacterLogsSender = CharacterLog::whereNotNull('sender_alias')->get(); - if($aliasCharacterLogs->count()) { - foreach($aliasCharacterLogs as $characterLog) { + if ($aliasCharacterLogs->count()) { + foreach ($aliasCharacterLogs as $characterLog) { $userAlias = UserAlias::where('site', 'deviantart')->where('alias', $characterLog->recipient_alias)->first(); - if($userAlias) { + if ($userAlias) { $characterLog->update(['recipient_alias' => null, 'recipient_id' => $userAlias->user_id]); - } - elseif(!$userAlias) { + } elseif (!$userAlias) { $alias = $characterLog->recipient_alias; $characterLog->update(['recipient_alias' => null, 'recipient_url' => 'https://deviantart.com/'.$alias]); } } - foreach($aliasCharacterLogsSender as $characterLog) { + foreach ($aliasCharacterLogsSender as $characterLog) { $userAlias = UserAlias::where('site', 'deviantart')->where('alias', $characterLog->sender_alias)->first(); - if($userAlias) { + if ($userAlias) { $characterLog->update(['sender_alias' => null, 'sender_id' => $userAlias->user_id]); - } - elseif(!$userAlias) { + } elseif (!$userAlias) { $alias = $characterLog->sender_alias; $characterLog->update(['sender_alias' => null, 'sender_url' => 'https://deviantart.com/'.$alias]); } } - $this->info("Migrated: Character log aliases"); + $this->info('Migrated: Character log aliases'); + } else { + $this->line('Skipped: Character log aliases (nothing to migrate)'); } - else $this->line("Skipped: Character log aliases (nothing to migrate)"); + } else { + $this->line('Skipped: Character log aliases (column no longer exists)'); } - else $this->line("Skipped: Character log aliases (column no longer exists)"); - if(Schema::hasColumn('user_character_log', 'recipient_alias') || Schema::hasColumn('user_character_log', 'sender_alias')) { + if (Schema::hasColumn('user_character_log', 'recipient_alias') || Schema::hasColumn('user_character_log', 'sender_alias')) { // Get character logs with a set recipient alias $aliasUserCharacterLogs = UserCharacterLog::whereNotNull('recipient_alias')->get(); $aliasUserCharacterLogsSender = UserCharacterLog::whereNotNull('sender_alias')->get(); - if($aliasUserCharacterLogs->count() || $aliasUserCharacterLogsSender->count()) { - foreach($aliasUserCharacterLogs as $characterLog) { + if ($aliasUserCharacterLogs->count() || $aliasUserCharacterLogsSender->count()) { + foreach ($aliasUserCharacterLogs as $characterLog) { $userAlias = UserAlias::where('site', 'deviantart')->where('alias', $characterLog->recipient_alias)->first(); - if($userAlias) { + if ($userAlias) { $characterLog->update(['recipient_alias' => null, 'recipient_id' => $userAlias->user_id]); - } - elseif(!$userAlias) { + } elseif (!$userAlias) { $alias = $characterLog->recipient_alias; $characterLog->update(['recipient_alias' => null, 'recipient_url' => 'https://deviantart.com/'.$alias]); } } - foreach($aliasUserCharacterLogsSender as $characterLog) { + foreach ($aliasUserCharacterLogsSender as $characterLog) { $userAlias = UserAlias::where('site', 'deviantart')->where('alias', $characterLog->sender_alias)->first(); - if($userAlias) { + if ($userAlias) { $characterLog->update(['sender_alias' => null, 'sender_id' => $userAlias->user_id]); - } - elseif(!$userAlias) { + } elseif (!$userAlias) { $alias = $characterLog->sender_alias; $characterLog->update(['sender_alias' => null, 'sender_url' => 'https://deviantart.com/'.$alias]); } } - $this->info("Migrated: User character log aliases"); + $this->info('Migrated: User character log aliases'); + } else { + $this->line('Skipped: User character log aliases (nothing to migrate)'); } - else $this->line("Skipped: User character log aliases (nothing to migrate)"); + } else { + $this->line('Skipped: User character log aliases (column no longer exists)'); } - else $this->line("Skipped: User character log aliases (column no longer exists)"); - if(Schema::hasColumn('items', 'artist_alias')) { + if (Schema::hasColumn('items', 'artist_alias')) { // Get character logs with a set recipient alias $aliasItemArtists = Item::whereNotNull('artist_alias')->get(); - if($aliasItemArtists->count()) { - foreach($aliasItemArtists as $itemArtist) { + if ($aliasItemArtists->count()) { + foreach ($aliasItemArtists as $itemArtist) { $userAlias = UserAlias::where('site', 'deviantart')->where('alias', $itemArtist->artist_alias)->first(); - if($userAlias) { + if ($userAlias) { $itemArtist->update(['artist_alias' => null, 'artist_id' => $userAlias->user_id]); - } - elseif(!$userAlias) { + } elseif (!$userAlias) { $alias = $itemArtist->artist_alias; $itemArtist->update(['artist_alias' => null, 'artist_url' => 'https://deviantart.com/'.$alias]); } } - $this->info("Migrated: Item artist aliases"); + $this->info('Migrated: Item artist aliases'); + } else { + $this->line('Skipped: Item artist aliases (nothing to migrate)'); } - else $this->line("Skipped: Item artist aliases (nothing to migrate)"); + } else { + $this->line('Skipped: Item artist aliases (column no longer exists)'); } - else $this->line("Skipped: Item artist aliases (column no longer exists)"); - if($this->option('drop-columns')) { + if ($this->option('drop-columns')) { // Drop alias columns from the impacted tables. Schema::table('users', function (Blueprint $table) { $table->dropColumn('alias'); @@ -265,11 +264,14 @@ public function handle() // $table->dropColumn('artist_alias'); }); - $this->info("Dropped alias columns"); + $this->info('Dropped alias columns'); + } else { + $this->line('Skipped: Dropping alias columns'); } - else $this->line("Skipped: Dropping alias columns"); $this->line("\nAlias information migrated!"); - if(!$this->option('drop-columns')) $this->line("After checking that all data has been moved from them,\nrun again with --drop-columns to drop alias columns if desired."); + if (!$this->option('drop-columns')) { + $this->line("After checking that all data has been moved from them,\nrun again with --drop-columns to drop alias columns if desired."); + } } } diff --git a/app/Console/Commands/SetupAdminUser.php b/app/Console/Commands/SetupAdminUser.php index 096f8ec963..7418703691 100644 --- a/app/Console/Commands/SetupAdminUser.php +++ b/app/Console/Commands/SetupAdminUser.php @@ -2,17 +2,15 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; - use App; -use Carbon\Carbon; -use App\Services\UserService; +use App\Models\Rank\Rank; use App\Models\User\User; use App\Models\User\UserAlias; -use App\Models\Rank\Rank; +use App\Services\UserService; +use Carbon\Carbon; +use Illuminate\Console\Command; -class SetupAdminUser extends Command -{ +class SetupAdminUser extends Command { /** * The name and signature of the console command. * @@ -29,11 +27,8 @@ class SetupAdminUser extends Command /** * Create a new command instance. - * - * @return void */ - public function __construct() - { + public function __construct() { parent::__construct(); } @@ -42,28 +37,26 @@ public function __construct() * * @return mixed */ - public function handle() - { + public function handle() { $this->info('********************'); $this->info('* ADMIN USER SETUP *'); $this->info('********************'."\n"); // First things first, check if user ranks exist... - if(!Rank::count()) { - + if (!Rank::count()) { // These need to be created even if the seeder isn't run for the site to work correctly. $adminRank = Rank::create([ - 'name' => 'Admin', + 'name' => 'Admin', 'description' => 'The site admin. Has the ability to view/edit any data on the site.', - 'sort' => 1 + 'sort' => 1, ]); Rank::create([ - 'name' => 'Member', + 'name' => 'Member', 'description' => 'A regular member of the site.', - 'sort' => 0 + 'sort' => 0, ]); - $this->line("User ranks not found. Default user ranks (admin and basic member) created."); + $this->line('User ranks not found. Default user ranks (admin and basic member) created.'); } // Otherwise, grab the rank with the highest "sort" value. (This is the admin rank.) else { @@ -72,128 +65,126 @@ public function handle() // Check if the admin user exists... $user = User::where('rank_id', $adminRank->id)->first(); - if(!$user) { - + if (!$user) { $this->line('Setting up admin account. This account will have access to all site data, please make sure to keep the email and password secret!'); $name = $this->anticipate('Username', ['Admin', 'System']); $email = $this->ask('Email Address'); $password = $this->secret('Password (hidden)'); $this->line("\nUsername: ".$name); - $this->line("Email: ".$email); - $confirm = $this->confirm("Proceed to create account with this information?"); + $this->line('Email: '.$email); + $confirm = $this->confirm('Proceed to create account with this information?'); // If env variables indicate a local instance, double-check // and then if so, help them set up verified email and alias - if(App::environment('local')) { - if($this->confirm('Are you on a local/testing instance and not a live site?')) { - if($this->confirm('Would you like to mark your email address as verified and enter an alias now?')) { + if (App::environment('local')) { + if ($this->confirm('Are you on a local/testing instance and not a live site?')) { + if ($this->confirm('Would you like to mark your email address as verified and enter an alias now?')) { $verifiedAt = Carbon::now(); $this->line('Provide an alias. By default, this will be entered as a deviantArt account name, but (assuming a local/testing environment) you may use any username.'); $alias = $this->ask('What alias would you like to use?'); } - } - else { + } else { $this->info('Please adjust your APP_ENV to Production and APP_DEBUG to false in your .env file before continuing set-up!'); + return; } } - if($confirm) { + if ($confirm) { $service = new UserService; $user = $service->createUser([ - 'name' => $name, - 'email' => $email, - 'rank_id' => $adminRank->id, + 'name' => $name, + 'email' => $email, + 'rank_id' => $adminRank->id, 'password' => $password, - 'dob' => [ - 'day' => '01', + 'dob' => [ + 'day' => '01', 'month' => '01', - 'year' => '1970' + 'year' => '1970', ], - 'has_alias' => isset($alias) ? 1 : 0 + 'has_alias' => isset($alias) ? 1 : 0, ]); - if(isset($verifiedAt)) { + if (isset($verifiedAt)) { $user->email_verified_at = $verifiedAt; $user->save(); } - if(isset($alias)) { + if (isset($alias)) { UserAlias::create([ - 'user_id' => $user->id, - 'site' => 'deviantart', - 'alias' => $alias, + 'user_id' => $user->id, + 'site' => 'deviantart', + 'alias' => $alias, 'is_primary_alias' => 1, - 'is_visible' => 1 + 'is_visible' => 1, ]); } $this->line('Admin account created. You can now log in with the registered email and password.'); $this->line('If necessary, you can run this command again to change the email address and password of the admin account.'); + return; } - } - else { + } else { // Change the admin email/password. Honestly you can do this with the forgotten password feature... - $this->line('Admin account [' . $user->name . '] already exists.'); - if($this->confirm("Reset email address and password for this account?")) { + $this->line('Admin account ['.$user->name.'] already exists.'); + if ($this->confirm('Reset email address and password for this account?')) { $email = $this->ask('Email Address'); $password = $this->secret('Password (hidden)'); $this->line("\nEmail: ".$email); - if($this->confirm("Proceed to change email address and password?")) { + if ($this->confirm('Proceed to change email address and password?')) { $service = new UserService; $service->updateUser([ - 'id' => $user->id, - 'email' => $email, - 'password' => $password + 'id' => $user->id, + 'email' => $email, + 'password' => $password, ]); $this->line('Admin account email and password changed.'); - } } // If env variables indicate a local instance, double-check // and then if so, help them set up verified email and alias - if(App::environment('local')) { - if($this->confirm('Are you on a local/testing instance and not a live site?')) { - if($this->confirm('Would you like to mark your email address as verified?')) { + if (App::environment('local')) { + if ($this->confirm('Are you on a local/testing instance and not a live site?')) { + if ($this->confirm('Would you like to mark your email address as verified?')) { $verifiedAt = Carbon::now(); } - if(!$user->has_alias && $this->confirm('Would you like to enter an alias now?')) { + if (!$user->has_alias && $this->confirm('Would you like to enter an alias now?')) { $this->line('Provide an alias. By default, this will be entered as a deviantArt account name, but (assuming a local/testing environment) you may use any username.'); $alias = $this->ask('What alias would you like to use?'); } - } - else { + } else { $this->info('Please adjust your APP_ENV to Production and APP_DEBUG to false in your .env file before continuing set-up!'); + return; } - if(isset($verifiedAt)) { + if (isset($verifiedAt)) { $this->line('Marking email address as verified...'); $user->email_verified_at = $verifiedAt; $user->save(); } - if(isset($alias)) { + if (isset($alias)) { $this->line('Adding user alias...'); $user->update(['has_alias' => 1]); UserAlias::create([ - 'user_id' => $user->id, - 'site' => 'deviantart', - 'alias' => $alias, + 'user_id' => $user->id, + 'site' => 'deviantart', + 'alias' => $alias, 'is_primary_alias' => 1, - 'is_visible' => 1 + 'is_visible' => 1, ]); } $this->line('Updates complete.'); } + return; } $this->line('Action cancelled.'); - } } diff --git a/app/Console/Commands/UpdateExtensionTracker.php b/app/Console/Commands/UpdateExtensionTracker.php index f334f1a2a5..5c1f33bd6a 100644 --- a/app/Console/Commands/UpdateExtensionTracker.php +++ b/app/Console/Commands/UpdateExtensionTracker.php @@ -2,12 +2,11 @@ namespace App\Console\Commands; -use Illuminate\Console\Command; -use DB; use Config; +use DB; +use Illuminate\Console\Command; -class UpdateExtensionTracker extends Command -{ +class UpdateExtensionTracker extends Command { /** * The name and signature of the console command. * @@ -24,11 +23,8 @@ class UpdateExtensionTracker extends Command /** * Create a new command instance. - * - * @return void */ - public function __construct() - { + public function __construct() { parent::__construct(); } @@ -37,8 +33,7 @@ public function __construct() * * @return mixed */ - public function handle() - { + public function handle() { $extensions = Config::get('lorekeeper.extension_tracker'); $this->info("\n".'****************************'); @@ -47,38 +42,35 @@ public function handle() $this->line('Adding site extensions...existing entries will be updated.'."\n"); - foreach($extensions as $data) - { + foreach ($extensions as $data) { $extension = DB::table('site_extensions')->where('key', $data['key']); - if(!$extension->exists()) - { + if (!$extension->exists()) { DB::table('site_extensions')->insert([ - 'key' => $data['key'], + 'key' => $data['key'], 'wiki_key' => $data['wiki_key'], 'creators' => $data['creators'], - 'version' => $data['version'], + 'version' => $data['version'], ]); $this->info('Added: '.$data['key'].' / Version: '.$data['version']); - } - elseif($extension->first()->version != $data['version']) - { + } elseif ($extension->first()->version != $data['version']) { $this->info(ucfirst($data['key']).' version mismatch. Old version: '.$extension->first()->version.' / New version: '.$data['version']); $confirm = $this->confirm('Do you want to update the listed version of '.$data['key'].' to '.$data['version'].'? This will not affect any other files.'); - if($confirm){ + if ($confirm) { DB::table('site_extensions')->where('key', $data['key'])->update([ - 'key' => $data['key'], + 'key' => $data['key'], 'wiki_key' => $data['wiki_key'], 'creators' => $data['creators'], - 'version' => $data['version'], + 'version' => $data['version'], ]); $this->info('Updated: '.$data['key'].' / Version: '.$data['version']); + } else { + $this->line('Skipped: '.$data['key'].' / Version: '.$extension->first()->version); } - else $this->line('Skipped: '.$data['key'].' / Version: '.$extension->first()->version); + } else { + $this->line('Skipped: '.$data['key'].' / Version: '.$data['version']); } - else $this->line('Skipped: '.$data['key'].' / Version: '.$data['version']); } - - $this->info("\n".'All extensions are in tracker.'."\n"); + $this->info("\n".'All extensions are in tracker.'."\n"); } } diff --git a/app/Console/Commands/UpdateLorekeeperV2.php b/app/Console/Commands/UpdateLorekeeperV2.php index 129416f842..88201c547b 100644 --- a/app/Console/Commands/UpdateLorekeeperV2.php +++ b/app/Console/Commands/UpdateLorekeeperV2.php @@ -5,8 +5,7 @@ use App\Models\Comment; use Illuminate\Console\Command; -class UpdateLorekeeperV2 extends Command -{ +class UpdateLorekeeperV2 extends Command { /** * The name and signature of the console command. * @@ -23,11 +22,8 @@ class UpdateLorekeeperV2 extends Command /** * Create a new command instance. - * - * @return void */ - public function __construct() - { + public function __construct() { parent::__construct(); } @@ -36,15 +32,14 @@ public function __construct() * * @return int */ - public function handle() - { + public function handle() { $this->info('**************************'); $this->info('* UPDATE LOREKEEPER (V2) *'); $this->info('**************************'."\n"); // Check if the user has run composer $this->info('This command should be run after updating packages using composer.'); - if($this->confirm('Have you run the composer update command or equivalent?')) { + if ($this->confirm('Have you run the composer update command or equivalent?')) { // Migrate $this->line('Running migrations...'); $this->call('migrate'); @@ -63,33 +58,37 @@ public function handle() $this->line("\n".'Updating comments...'); // Folding in fix-child-comment-types for tidiness $childComments = Comment::whereNotNull('child_id')->get(); - if($childComments->count()) { + if ($childComments->count()) { $this->line('Updating '.$childComments->count().' child comments...'); - foreach($childComments as $comment) { + foreach ($childComments as $comment) { $parent = Comment::find($comment->child_id); - if(isset($parent->type) && $comment->type != $parent->type) + if (isset($parent->type) && $comment->type != $parent->type) { $comment->update(['type' => $parent->type]); + } } $this->info('Child comments updated!'); + } else { + $this->line('No child comments to update!'); } - else $this->line('No child comments to update!'); // Folding in update-sales-comments for tidiness $salesComments = Comment::where('commentable_type', 'App\Models\Sales')->get(); - if($salesComments->count()) { + if ($salesComments->count()) { $this->line('Updating '.$salesComments->count().' sales comments...'); - foreach($salesComments as $comment) { + foreach ($salesComments as $comment) { $comment->commentable_type = 'App\Models\Sales\Sales'; $comment->save(); } $this->info('Sales comments updated!'); + } else { + $this->line('No sales comments to update!'); } - else $this->line('No sales comments to update!'); // Migrate aliases $this->line("\n".'Updating alias information...'); $this->call('migrate-aliases'); + } else { + $this->line('Aborting! Please run composer update and then run this command again.'); } - else $this->line('Aborting! Please run composer update and then run this command again.'); } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2ec3d9aab5..db1287efb7 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -5,8 +5,7 @@ use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; -class Kernel extends ConsoleKernel -{ +class Kernel extends ConsoleKernel { /** * The Artisan commands provided by your application. * @@ -18,28 +17,20 @@ class Kernel extends ConsoleKernel /** * Define the application's command schedule. - * - * @param \Illuminate\Console\Scheduling\Schedule $schedule - * @return void */ - protected function schedule(Schedule $schedule) - { + protected function schedule(Schedule $schedule) { $schedule->command('check-news') - ->everyMinute(); + ->everyMinute(); $schedule->exec('rm public/images/avatars/*.tmp') - ->daily(); + ->daily(); $schedule->command('check-sales') - ->everyMinute(); - + ->everyMinute(); } /** * Register the commands for the application. - * - * @return void */ - protected function commands() - { + protected function commands() { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); diff --git a/app/Events/CommentCreated.php b/app/Events/CommentCreated.php index 3a6c243185..9bc8c56b02 100644 --- a/app/Events/CommentCreated.php +++ b/app/Events/CommentCreated.php @@ -2,22 +2,18 @@ namespace App\Events; -use Illuminate\Queue\SerializesModels; use App\Models\Comment; +use Illuminate\Queue\SerializesModels; -class CommentCreated -{ +class CommentCreated { use SerializesModels; public $comment; /** * Create a new event instance. - * - * @return void */ - public function __construct(Comment $comment) - { + public function __construct(Comment $comment) { $this->comment = $comment; } } diff --git a/app/Events/CommentDeleted.php b/app/Events/CommentDeleted.php index 2eb694982d..af5f379032 100644 --- a/app/Events/CommentDeleted.php +++ b/app/Events/CommentDeleted.php @@ -2,22 +2,18 @@ namespace App\Events; -use Illuminate\Queue\SerializesModels; use App\Models\Comment; +use Illuminate\Queue\SerializesModels; -class CommentDeleted -{ +class CommentDeleted { use SerializesModels; public $comment; /** * Create a new event instance. - * - * @return void */ - public function __construct(Comment $comment) - { + public function __construct(Comment $comment) { $this->comment = $comment; } } diff --git a/app/Events/CommentUpdated.php b/app/Events/CommentUpdated.php index 0c276f32b8..86d0922580 100644 --- a/app/Events/CommentUpdated.php +++ b/app/Events/CommentUpdated.php @@ -2,22 +2,18 @@ namespace App\Events; -use Illuminate\Queue\SerializesModels; use App\Models\Comment; +use Illuminate\Queue\SerializesModels; -class CommentUpdated -{ +class CommentUpdated { use SerializesModels; public $comment; /** * Create a new event instance. - * - * @return void */ - public function __construct(Comment $comment) - { + public function __construct(Comment $comment) { $this->comment = $comment; } } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 376174d4ed..5ea241a030 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -2,12 +2,11 @@ namespace App\Exceptions; -use Throwable; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Validation\ValidationException; +use Throwable; -class Handler extends ExceptionHandler -{ +class Handler extends ExceptionHandler { /** * A list of the exception types that are not reported. * @@ -30,11 +29,9 @@ class Handler extends ExceptionHandler /** * Report or log an exception. * - * @param \Exception $exception - * @return void + * @param \Exception $exception */ - public function report(Throwable $exception) - { + public function report(Throwable $exception) { if ($exception instanceof ValidationException) { foreach ($exception->validator->errors()->all() as $message) { flash($message)->error(); @@ -47,12 +44,12 @@ public function report(Throwable $exception) /** * Render an exception into an HTTP response. * - * @param \Illuminate\Http\Request $request - * @param \Exception $exception + * @param \Illuminate\Http\Request $request + * @param \Exception $exception + * * @return \Illuminate\Http\Response */ - public function render($request, Throwable $exception) - { + public function render($request, Throwable $exception) { return parent::render($request, $exception); } } diff --git a/app/Facades/Notifications.php b/app/Facades/Notifications.php index 2c39eaf656..682c9b3159 100644 --- a/app/Facades/Notifications.php +++ b/app/Facades/Notifications.php @@ -5,7 +5,7 @@ use Illuminate\Support\Facades\Facade; class Notifications extends Facade { - - protected static function getFacadeAccessor() { return 'notifications'; } - -} \ No newline at end of file + protected static function getFacadeAccessor() { + return 'notifications'; + } +} diff --git a/app/Facades/Settings.php b/app/Facades/Settings.php index d41cac1272..c75b230e7b 100644 --- a/app/Facades/Settings.php +++ b/app/Facades/Settings.php @@ -5,7 +5,7 @@ use Illuminate\Support\Facades\Facade; class Settings extends Facade { - - protected static function getFacadeAccessor() { return 'settings'; } - -} \ No newline at end of file + protected static function getFacadeAccessor() { + return 'settings'; + } +} diff --git a/app/Helpers/AssetHelpers.php b/app/Helpers/AssetHelpers.php index c796899d4d..b455f46cc7 100644 --- a/app/Helpers/AssetHelpers.php +++ b/app/Helpers/AssetHelpers.php @@ -14,92 +14,122 @@ * Gets the asset keys for an array depending on whether the * assets being managed are owned by a user or character. * - * @param bool $isCharacter + * @param bool $isCharacter + * * @return array */ -function getAssetKeys($isCharacter = false) -{ - if(!$isCharacter) return ['items', 'currencies', 'raffle_tickets', 'loot_tables', 'user_items', 'characters']; - else return ['currencies', 'items', 'character_items', 'loot_tables']; +function getAssetKeys($isCharacter = false) { + if (!$isCharacter) { + return ['items', 'currencies', 'raffle_tickets', 'loot_tables', 'user_items', 'characters']; + } else { + return ['currencies', 'items', 'character_items', 'loot_tables']; + } } /** * Gets the model name for an asset type. * The asset type has to correspond to one of the asset keys above. * - * @param string $type - * @param bool $namespaced + * @param string $type + * @param bool $namespaced + * * @return string */ -function getAssetModelString($type, $namespaced = true) -{ - switch($type) - { +function getAssetModelString($type, $namespaced = true) { + switch ($type) { case 'items': - if($namespaced) return '\App\Models\Item\Item'; - else return 'Item'; + if ($namespaced) { + return '\App\Models\Item\Item'; + } else { + return 'Item'; + } break; case 'currencies': - if($namespaced) return '\App\Models\Currency\Currency'; - else return 'Currency'; + if ($namespaced) { + return '\App\Models\Currency\Currency'; + } else { + return 'Currency'; + } break; case 'raffle_tickets': - if($namespaced) return '\App\Models\Raffle\Raffle'; - else return 'Raffle'; + if ($namespaced) { + return '\App\Models\Raffle\Raffle'; + } else { + return 'Raffle'; + } break; case 'loot_tables': - if($namespaced) return '\App\Models\Loot\LootTable'; - else return 'LootTable'; + if ($namespaced) { + return '\App\Models\Loot\LootTable'; + } else { + return 'LootTable'; + } break; case 'user_items': - if($namespaced) return '\App\Models\User\UserItem'; - else return 'UserItem'; + if ($namespaced) { + return '\App\Models\User\UserItem'; + } else { + return 'UserItem'; + } break; case 'characters': - if($namespaced) return '\App\Models\Character\Character'; - else return 'Character'; + if ($namespaced) { + return '\App\Models\Character\Character'; + } else { + return 'Character'; + } break; case 'character_items': - if($namespaced) return '\App\Models\Character\CharacterItem'; - else return 'CharacterItem'; + if ($namespaced) { + return '\App\Models\Character\CharacterItem'; + } else { + return 'CharacterItem'; + } break; } + return null; } /** * Initialises a new blank assets array, keyed by the asset type. * - * @param bool $isCharacter + * @param bool $isCharacter + * * @return array */ -function createAssetsArray($isCharacter = false) -{ +function createAssetsArray($isCharacter = false) { $keys = getAssetKeys($isCharacter); $assets = []; - foreach($keys as $key) $assets[$key] = []; + foreach ($keys as $key) { + $assets[$key] = []; + } + return $assets; } /** * Merges 2 asset arrays. * - * @param array $first - * @param array $second + * @param array $first + * @param array $second + * * @return array */ -function mergeAssetsArrays($first, $second) -{ +function mergeAssetsArrays($first, $second) { $keys = getAssetKeys(); - foreach($keys as $key) - foreach($second[$key] as $item) + foreach ($keys as $key) { + foreach ($second[$key] as $item) { addAsset($first, $item['asset'], $item['quantity']); + } + } + return $first; } @@ -107,15 +137,19 @@ function mergeAssetsArrays($first, $second) * Adds an asset to the given array. * If the asset already exists, it adds to the quantity. * - * @param array $array - * @param mixed $asset - * @param int $quantity + * @param array $array + * @param mixed $asset + * @param int $quantity */ -function addAsset(&$array, $asset, $quantity = 1) -{ - if(!$asset) return; - if(isset($array[$asset->assetType][$asset->id])) $array[$asset->assetType][$asset->id]['quantity'] += $quantity; - else $array[$asset->assetType][$asset->id] = ['asset' => $asset, 'quantity' => $quantity]; +function addAsset(&$array, $asset, $quantity = 1) { + if (!$asset) { + return; + } + if (isset($array[$asset->assetType][$asset->id])) { + $array[$asset->assetType][$asset->id]['quantity'] += $quantity; + } else { + $array[$asset->assetType][$asset->id] = ['asset' => $asset, 'quantity' => $quantity]; + } } /** @@ -123,21 +157,22 @@ function addAsset(&$array, $asset, $quantity = 1) * where each asset is listed in [id => quantity] format. * json_encode this and store in the data attribute. * - * @param array $array - * @param bool $isCharacter + * @param array $array + * @param bool $isCharacter + * * @return array */ -function getDataReadyAssets($array, $isCharacter = false) -{ +function getDataReadyAssets($array, $isCharacter = false) { $result = []; - foreach($array as $key => $type) - { - if($type && !isset($result[$key])) $result[$key] = []; - foreach($type as $assetId => $assetData) - { + foreach ($array as $key => $type) { + if ($type && !isset($result[$key])) { + $result[$key] = []; + } + foreach ($type as $assetId => $assetData) { $result[$key][$assetId] = $assetData['quantity']; } } + return $result; } @@ -146,27 +181,24 @@ function getDataReadyAssets($array, $isCharacter = false) * basically reversing the above function. * Use the data attribute after json_decode()ing it. * - * @param array $array + * @param array $array + * * @return array */ -function parseAssetData($array) -{ +function parseAssetData($array) { $assets = createAssetsArray(); - foreach($array as $key => $contents) - { + foreach ($array as $key => $contents) { $model = getAssetModelString($key); - if($model) - { - foreach($contents as $id => $quantity) - { + if ($model) { + foreach ($contents as $id => $quantity) { $assets[$key][$id] = [ - 'asset' => $model::find($id), - 'quantity' => $quantity + 'asset' => $model::find($id), + 'quantity' => $quantity, ]; } - } } + return $assets; } @@ -174,58 +206,62 @@ function parseAssetData($array) * Distributes the assets in an assets array to the given recipient (user). * Loot tables will be rolled before distribution. * - * @param array $assets - * @param \App\Models\User\User $sender - * @param \App\Models\User\User $recipient - * @param string $logType - * @param string $data + * @param array $assets + * @param \App\Models\User\User $sender + * @param \App\Models\User\User $recipient + * @param string $logType + * @param string $data + * * @return array */ -function fillUserAssets($assets, $sender, $recipient, $logType, $data) -{ +function fillUserAssets($assets, $sender, $recipient, $logType, $data) { // Roll on any loot tables - if(isset($assets['loot_tables'])) - { - foreach($assets['loot_tables'] as $table) - { + if (isset($assets['loot_tables'])) { + foreach ($assets['loot_tables'] as $table) { $assets = mergeAssetsArrays($assets, $table['asset']->roll($table['quantity'])); } unset($assets['loot_tables']); } - foreach($assets as $key => $contents) - { - if($key == 'items' && count($contents)) - { + foreach ($assets as $key => $contents) { + if ($key == 'items' && count($contents)) { $service = new \App\Services\InventoryManager; - foreach($contents as $asset) - if(!$service->creditItem($sender, $recipient, $logType, $data, $asset['asset'], $asset['quantity'])) return false; - } - elseif($key == 'currencies' && count($contents)) - { + foreach ($contents as $asset) { + if (!$service->creditItem($sender, $recipient, $logType, $data, $asset['asset'], $asset['quantity'])) { + return false; + } + } + } elseif ($key == 'currencies' && count($contents)) { $service = new \App\Services\CurrencyManager; - foreach($contents as $asset) - if(!$service->creditCurrency($sender, $recipient, $logType, $data['data'], $asset['asset'], $asset['quantity'])) return false; - } - elseif($key == 'raffle_tickets' && count($contents)) - { + foreach ($contents as $asset) { + if (!$service->creditCurrency($sender, $recipient, $logType, $data['data'], $asset['asset'], $asset['quantity'])) { + return false; + } + } + } elseif ($key == 'raffle_tickets' && count($contents)) { $service = new \App\Services\RaffleManager; - foreach($contents as $asset) - if(!$service->addTicket($recipient, $asset['asset'], $asset['quantity'])) return false; - } - elseif($key == 'user_items' && count($contents)) - { + foreach ($contents as $asset) { + if (!$service->addTicket($recipient, $asset['asset'], $asset['quantity'])) { + return false; + } + } + } elseif ($key == 'user_items' && count($contents)) { $service = new \App\Services\InventoryManager; - foreach($contents as $asset) - if(!$service->moveStack($sender, $recipient, $logType, $data, $asset['asset'])) return false; - } - elseif($key == 'characters' && count($contents)) - { + foreach ($contents as $asset) { + if (!$service->moveStack($sender, $recipient, $logType, $data, $asset['asset'])) { + return false; + } + } + } elseif ($key == 'characters' && count($contents)) { $service = new \App\Services\CharacterManager; - foreach($contents as $asset) - if(!$service->moveCharacter($asset['asset'], $recipient, $data, $asset['quantity'], $logType)) return false; + foreach ($contents as $asset) { + if (!$service->moveCharacter($asset['asset'], $recipient, $data, $asset['quantity'], $logType)) { + return false; + } + } } } + return $assets; } @@ -233,43 +269,47 @@ function fillUserAssets($assets, $sender, $recipient, $logType, $data) * Distributes the assets in an assets array to the given recipient (character). * Loot tables will be rolled before distribution. * - * @param array $assets - * @param \App\Models\User\User $sender - * @param \App\Models\Character\Character $recipient - * @param string $logType - * @param string $data + * @param array $assets + * @param \App\Models\User\User $sender + * @param \App\Models\Character\Character $recipient + * @param string $logType + * @param string $data + * @param mixed|null $submitter + * * @return array */ -function fillCharacterAssets($assets, $sender, $recipient, $logType, $data, $submitter = null) -{ - if(!Config::get('lorekeeper.extensions.character_reward_expansion.default_recipient') && $recipient->user) $item_recipient = $recipient->user; - else $item_recipient = $submitter; - +function fillCharacterAssets($assets, $sender, $recipient, $logType, $data, $submitter = null) { + if (!Config::get('lorekeeper.extensions.character_reward_expansion.default_recipient') && $recipient->user) { + $item_recipient = $recipient->user; + } else { + $item_recipient = $submitter; + } // Roll on any loot tables - if(isset($assets['loot_tables'])) - { - foreach($assets['loot_tables'] as $table) - { + if (isset($assets['loot_tables'])) { + foreach ($assets['loot_tables'] as $table) { $assets = mergeAssetsArrays($assets, $table['asset']->roll($table['quantity'])); } unset($assets['loot_tables']); } - foreach($assets as $key => $contents) - { - if($key == 'currencies' && count($contents)) - { + foreach ($assets as $key => $contents) { + if ($key == 'currencies' && count($contents)) { $service = new \App\Services\CurrencyManager; - foreach($contents as $asset) - if(!$service->creditCurrency($sender, ( $asset['asset']->is_character_owned ? $recipient : $item_recipient), $logType, $data['data'], $asset['asset'], $asset['quantity'])) return false; - } - elseif($key == 'items' && count($contents)) - { + foreach ($contents as $asset) { + if (!$service->creditCurrency($sender, ($asset['asset']->is_character_owned ? $recipient : $item_recipient), $logType, $data['data'], $asset['asset'], $asset['quantity'])) { + return false; + } + } + } elseif ($key == 'items' && count($contents)) { $service = new \App\Services\InventoryManager; - foreach($contents as $asset) - if(!$service->creditItem($sender, ( ($asset['asset']->category && $asset['asset']->category->is_character_owned) ? $recipient : $item_recipient), $logType, $data, $asset['asset'], $asset['quantity'])) return false; + foreach ($contents as $asset) { + if (!$service->creditItem($sender, (($asset['asset']->category && $asset['asset']->category->is_character_owned) ? $recipient : $item_recipient), $logType, $data, $asset['asset'], $asset['quantity'])) { + return false; + } + } } } + return $assets; } diff --git a/app/Helpers/Helpers.php b/app/Helpers/Helpers.php index 302c9bbd38..de654153ed 100644 --- a/app/Helpers/Helpers.php +++ b/app/Helpers/Helpers.php @@ -12,18 +12,20 @@ /** * Returns class name if the current URL corresponds to the given path. * - * @param string $path - * @param string $class + * @param string $path + * @param string $class + * * @return string */ function set_active($path, $class = 'active') { - return call_user_func_array('Request::is', (array)$path) ? $class : ''; + return call_user_func_array('Request::is', (array) $path) ? $class : ''; } /** * Adds a help icon with a tooltip. * - * @param string $text + * @param string $text + * * @return string */ function add_help($text) { @@ -33,23 +35,30 @@ function add_help($text) { /** * Uses the given array to generate breadcrumb links. * - * @param array $links + * @param array $links + * * @return string */ function breadcrumbs($links) { $ret = '