Skip to content

Commit

Permalink
run composer lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ScuffedNewt committed Feb 22, 2024
1 parent a815d33 commit 25a721b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 42 deletions.
66 changes: 34 additions & 32 deletions app/Http/Controllers/Users/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ public function getNewSubmission(Request $request) {

if (config('lorekeeper.settings.allow_gallery_submissions_on_prompts')) {
$gallerySubmissions = GallerySubmission::where('user_id', Auth::user()->id)->where('status', 'Accepted')->orderBy('id', 'DESC')->get()->pluck('title', 'id');
// add "" around title and by "user" to differentiate from prompt submissions
$gallerySubmissions = $gallerySubmissions->map(function ($item, $key) {
return '"'.$item.'" by ' . Auth::user()->name;
return '"'.$item.'" by '.Auth::user()->name;
});
} else {
$gallerySubmissions = [];
Expand All @@ -101,17 +100,17 @@ public function getNewSubmission(Request $request) {
'closed' => $closed,
'isClaim' => false,
] + ($closed ? [] : [
'submission' => new Submission,
'prompts' => Prompt::active()->sortAlphabetical()->pluck('name', 'id')->toArray(),
'characterCurrencies' => Currency::where('is_character_owned', 1)->orderBy('sort_character', 'DESC')->pluck('name', 'id'),
'categories' => ItemCategory::visible(Auth::check() ? Auth::user() : null)->orderBy('sort', 'DESC')->get(),
'item_filter' => Item::orderBy('name')->released()->get()->keyBy('id'),
'items' => Item::orderBy('name')->released()->pluck('name', 'id'),
'character_items' => Item::whereIn('item_category_id', ItemCategory::where('is_character_owned', 1)->pluck('id')->toArray())->orderBy('name')->released()->pluck('name', 'id'),
'currencies' => Currency::where('is_user_owned', 1)->orderBy('name')->pluck('name', 'id'),
'inventory' => $inventory,
'page' => 'submission',
'expanded_rewards' => config('lorekeeper.extensions.character_reward_expansion.expanded'),
'submission' => new Submission,
'prompts' => Prompt::active()->sortAlphabetical()->pluck('name', 'id')->toArray(),
'characterCurrencies' => Currency::where('is_character_owned', 1)->orderBy('sort_character', 'DESC')->pluck('name', 'id'),
'categories' => ItemCategory::visible(Auth::check() ? Auth::user() : null)->orderBy('sort', 'DESC')->get(),
'item_filter' => Item::orderBy('name')->released()->get()->keyBy('id'),
'items' => Item::orderBy('name')->released()->pluck('name', 'id'),
'character_items' => Item::whereIn('item_category_id', ItemCategory::where('is_character_owned', 1)->pluck('id')->toArray())->orderBy('name')->released()->pluck('name', 'id'),
'currencies' => Currency::where('is_user_owned', 1)->orderBy('name')->pluck('name', 'id'),
'inventory' => $inventory,
'page' => 'submission',
'expanded_rewards' => config('lorekeeper.extensions.character_reward_expansion.expanded'),
'userGallerySubmissions' => $gallerySubmissions,
]));
}
Expand All @@ -133,9 +132,8 @@ public function getEditSubmission(Request $request, $id) {

if (config('lorekeeper.settings.allow_gallery_submissions_on_prompts')) {
$gallerySubmissions = GallerySubmission::where('user_id', Auth::user()->id)->where('status', 'Accepted')->orderBy('id', 'DESC')->get()->pluck('title', 'id');
// add "" around title and by "user" to differentiate from prompt submissions
$gallerySubmissions = $gallerySubmissions->map(function ($item, $key) {
return '"'.$item.'" by ' . Auth::user()->name;
return '"'.$item.'" by '.Auth::user()->name;
});
} else {
$gallerySubmissions = [];
Expand All @@ -145,19 +143,19 @@ public function getEditSubmission(Request $request, $id) {
'closed' => $closed,
'isClaim' => false,
] + ($closed ? [] : [
'submission' => $submission,
'prompts' => Prompt::active()->sortAlphabetical()->pluck('name', 'id')->toArray(),
'characterCurrencies' => Currency::where('is_character_owned', 1)->orderBy('sort_character', 'DESC')->pluck('name', 'id'),
'categories' => ItemCategory::orderBy('sort', 'DESC')->get(),
'item_filter' => Item::orderBy('name')->released()->get()->keyBy('id'),
'items' => Item::orderBy('name')->released()->pluck('name', 'id'),
'character_items' => Item::whereIn('item_category_id', ItemCategory::where('is_character_owned', 1)->pluck('id')->toArray())->orderBy('name')->released()->pluck('name', 'id'),
'currencies' => Currency::where('is_user_owned', 1)->orderBy('name')->pluck('name', 'id'),
'inventory' => $inventory,
'page' => 'submission',
'expanded_rewards' => config('lorekeeper.extensions.character_reward_expansion.expanded'),
'selectedInventory' => isset($submission->data['user']) ? parseAssetData($submission->data['user']) : null,
'count' => Submission::where('prompt_id', $submission->prompt_id)->where('status', 'Approved')->where('user_id', $submission->user_id)->count(),
'submission' => $submission,
'prompts' => Prompt::active()->sortAlphabetical()->pluck('name', 'id')->toArray(),
'characterCurrencies' => Currency::where('is_character_owned', 1)->orderBy('sort_character', 'DESC')->pluck('name', 'id'),
'categories' => ItemCategory::orderBy('sort', 'DESC')->get(),
'item_filter' => Item::orderBy('name')->released()->get()->keyBy('id'),
'items' => Item::orderBy('name')->released()->pluck('name', 'id'),
'character_items' => Item::whereIn('item_category_id', ItemCategory::where('is_character_owned', 1)->pluck('id')->toArray())->orderBy('name')->released()->pluck('name', 'id'),
'currencies' => Currency::where('is_user_owned', 1)->orderBy('name')->pluck('name', 'id'),
'inventory' => $inventory,
'page' => 'submission',
'expanded_rewards' => config('lorekeeper.extensions.character_reward_expansion.expanded'),
'selectedInventory' => isset($submission->data['user']) ? parseAssetData($submission->data['user']) : null,
'count' => Submission::where('prompt_id', $submission->prompt_id)->where('status', 'Approved')->where('user_id', $submission->user_id)->count(),
'userGallerySubmissions' => $gallerySubmissions,
]));
}
Expand Down Expand Up @@ -210,8 +208,12 @@ public function postNewSubmission(Request $request, SubmissionManager $service,
$request->only([
'url', 'prompt_id', 'comments', 'slug', 'character_rewardable_type', 'character_rewardable_id', 'character_rewardable_quantity',
'rewardable_type', 'rewardable_id', 'quantity', 'stack_id', 'stack_quantity', 'currency_id', 'currency_quantity',
'gallery_submission_id'
]), Auth::user(), false, $draft)) {
'gallery_submission_id',
]),
Auth::user(),
false,
$draft
)) {
if ($submission->status == 'Draft') {
flash('Draft created successfully.')->success();

Expand Down Expand Up @@ -251,13 +253,13 @@ public function postEditSubmission(Request $request, SubmissionManager $service,
if ($submit && $service->editSubmission($submission, $request->only([
'url', 'prompt_id', 'comments', 'slug', 'character_rewardable_type', 'character_rewardable_id', 'character_rewardable_quantity',
'rewardable_type', 'rewardable_id', 'quantity', 'stack_id', 'stack_quantity', 'currency_id', 'currency_quantity',
'gallery_submission_id'
'gallery_submission_id',
]), Auth::user(), false, $submit)) {
flash('Draft submitted successfully.')->success();
} elseif ($service->editSubmission($submission, $request->only([
'url', 'prompt_id', 'comments', 'slug', 'character_rewardable_type', 'character_rewardable_id', 'character_rewardable_quantity',
'rewardable_type', 'rewardable_id', 'quantity', 'stack_id', 'stack_quantity', 'currency_id', 'currency_quantity',
'gallery_submission_id'
'gallery_submission_id',
]), Auth::user())) {
flash('Draft saved successfully.')->success();

Expand Down
2 changes: 1 addition & 1 deletion app/Models/Submission/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Models\Submission;

use App\Models\Model;
use App\Models\Gallery\GallerySubmission;
use App\Models\Model;
use App\Models\Prompt\Prompt;
use App\Models\User\User;
use Carbon\Carbon;
Expand Down
16 changes: 8 additions & 8 deletions app/Services/SubmissionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function createSubmission($data, $user, $isClaim = false, $isDraft = fals
'data' => json_encode([
'user' => Arr::only(getDataReadyAssets($userAssets), ['user_items', 'currencies']),
'rewards' => getDataReadyAssets($promptRewards),
] + (config('lorekeeper.settings.allow_gallery_submissions_on_prompts') ? ['gallery_submission_id' => $data['gallery_submission_id'] ?? null] : []))
] + (config('lorekeeper.settings.allow_gallery_submissions_on_prompts') ? ['gallery_submission_id' => $data['gallery_submission_id'] ?? null] : [])),
]);

// Set characters that have been attached.
Expand Down Expand Up @@ -158,7 +158,7 @@ public function editSubmission($submission, $data, $user, $isClaim = false, $isS
'data' => json_encode([
'user' => Arr::only(getDataReadyAssets($userAssets), ['user_items', 'currencies']),
'rewards' => getDataReadyAssets($promptRewards),
] + (config('lorekeeper.settings.allow_gallery_submissions_on_prompts') ? ['gallery_submission_id' => $data['gallery_submission_id'] ?? null] : []))
] + (config('lorekeeper.settings.allow_gallery_submissions_on_prompts') ? ['gallery_submission_id' => $data['gallery_submission_id'] ?? null] : [])),
] + ($isClaim ? [] : ['prompt_id' => $prompt->id]));

return $this->commitReturn($submission);
Expand Down Expand Up @@ -216,8 +216,8 @@ public function cancelSubmission($data, $user) {
'staff_id' => $user->id,
'status' => 'Draft',
'data' => json_encode([
'user' => $userAssets,
'rewards' => getDataReadyAssets($promptRewards),
'user' => $userAssets,
'rewards' => getDataReadyAssets($promptRewards),
'gallery_submission_id' => $submission->data['gallery_submission_id'] ?? null,
]), // list of rewards and addons
]);
Expand All @@ -233,8 +233,8 @@ public function cancelSubmission($data, $user) {
'status' => 'Draft',
'updated_at' => Carbon::now(),
'data' => json_encode([
'user' => $userAssets,
'rewards' => getDataReadyAssets($promptRewards),
'user' => $userAssets,
'rewards' => getDataReadyAssets($promptRewards),
'gallery_submission_id' => $submission->data['gallery_submission_id'] ?? null,
]), // list of rewards and addons
]);
Expand Down Expand Up @@ -483,8 +483,8 @@ public function approveSubmission($data, $user) {
'staff_id' => $user->id,
'status' => 'Approved',
'data' => json_encode([
'user' => $addonData,
'rewards' => getDataReadyAssets($rewards),
'user' => $addonData,
'rewards' => getDataReadyAssets($rewards),
'gallery_submission_id' => $submission->data['gallery_submission_id'] ?? null,
]), // list of rewards
]);
Expand Down
2 changes: 1 addition & 1 deletion config/lorekeeper/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
| Allow Gallery Submissions on Prompts
|--------------------------------------------------------------------------
|
| Whether or not to allow gallery submissions on prompts.
| Whether or not to allow gallery submissions on prompts.
|
*/
'allow_gallery_submissions_on_prompts' => 1,
Expand Down

0 comments on commit 25a721b

Please sign in to comment.