Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
ScuffedNewt committed Oct 19, 2023
1 parent d80b5da commit fd2f63b
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 84 deletions.
26 changes: 26 additions & 0 deletions app/Http/Controllers/Users/InventoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,30 @@ private function postAct(Request $request) {

return redirect()->back();
}

/**
* Displays the user's sticker book.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function getStickerBook() {
$user = Auth::user();
$categories = ItemCategory::visible(Auth::check() ? Auth::user() : null)->orderBy('sort', 'DESC')->get();
$items = count($categories) ?
Item::released()
->orderByRaw('FIELD(item_category_id,'.implode(',', $categories->pluck('id')->toArray()).')')
->orderBy('name')
->get()
->groupBy('item_category_id') :
Item::released()
->orderBy('name')
->get()
->groupBy('item_category_id');

return view('home.sticker_book', [
'user' => $user,
'categories' => $categories->keyBy('id'),
'items' => $items,
]);
}
}
24 changes: 24 additions & 0 deletions app/Http/Controllers/Users/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,28 @@ public function getUserOwnCharacterFavorites(Request $request, $name) {
'favorites' => $this->user->characters->count() ? GallerySubmission::whereIn('id', $userFavorites)->whereIn('id', GalleryCharacter::whereIn('character_id', $userCharacters)->pluck('gallery_submission_id')->toArray())->visible(Auth::check() ? Auth::user() : null)->accepted()->orderBy('created_at', 'DESC')->paginate(20)->appends($request->query()) : null,
]);
}

/**
* Shows a user's sticker collection.
*/
public function getUserStickerBook(Request $request, $name) {
$user = $this->user;
$categories = ItemCategory::visible(Auth::check() ? Auth::user() : null)->orderBy('sort', 'DESC')->get();
$items = count($categories) ?
Item::released()
->orderByRaw('FIELD(item_category_id,'.implode(',', $categories->pluck('id')->toArray()).')')
->orderBy('name')
->get()
->groupBy('item_category_id') :
Item::released()
->orderBy('name')
->get()
->groupBy('item_category_id');

return view('user.sticker_book', [
'user' => $user,
'categories' => $categories->keyBy('id'),
'items' => $items,
]);
}
}
Loading

0 comments on commit fd2f63b

Please sign in to comment.