File tree Expand file tree Collapse file tree 4 files changed +50
-1
lines changed
Expand file tree Collapse file tree 4 files changed +50
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace App \Http \Controllers ;
6+
7+ use App \Domain \Dto \FeCard ;
8+ use App \Domain \Dto \FeDeck ;
9+ use Illuminate \Http \Request ;
10+ use Inertia \Inertia ;
11+ use Inertia \Response ;
12+
13+ class DeckCardsController extends Controller
14+ {
15+ public function show (Request $ req , int $ id ): Response
16+ {
17+ $ deck = $ req ->user ()->decks ()->find ($ id );
18+
19+ $ cards = $ deck ->cards ()->get ();
20+
21+ return Inertia::render ('DeckCards/Show ' , [
22+ 'cards ' => fn () => FeCard::collect ($ cards ),
23+ 'deck ' => fn () => FeDeck::from ($ deck ),
24+ ]);
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ import Authenticated from '@/Layouts/AuthenticatedLayout' ;
2+
3+ export default function Show ( {
4+ deck,
5+ cards,
6+ } : {
7+ deck : App . Domain . Dto . FeDeck ;
8+ cards : Array < App . Domain . Dto . FeCard > ;
9+ } ) {
10+ return (
11+ < Authenticated >
12+ < pre > { JSON . stringify ( deck , null , 2 ) } </ pre >
13+ < pre > { JSON . stringify ( cards , null , 2 ) } </ pre >
14+ </ Authenticated >
15+ ) ;
16+ }
Original file line number Diff line number Diff line change @@ -24,7 +24,9 @@ export default function DeckList({
2424 key = { deck . id }
2525 >
2626 < div className = "w-full p-2 bg-white/10 backdrop-blur-[3px] text-md font-semibold rounded-t-md" >
27- { deck . name }
27+ < Link href = { route ( 'deck.cards' , { id : deck . id } ) } >
28+ { deck . name }
29+ </ Link >
2830 </ div >
2931 < div className = "w-full p-2 bg-white/10 backdrop-blur-[3px] text-sm rounded-b-md" >
3032 < Link
Original file line number Diff line number Diff line change 22
33use App \Http \Controllers \CardController ;
44use App \Http \Controllers \DashboardController ;
5+ use App \Http \Controllers \DeckCardsController ;
56use App \Http \Controllers \DeckController ;
67use App \Http \Controllers \ImportCardsController ;
78use App \Http \Controllers \ProfileController ;
4243 Route::patch ('/decks/{id} ' , [DeckController::class, 'update ' ])
4344 ->whereNumber ('id ' )
4445 ->name ('deck.update ' );
46+
47+ Route::get ('/decks/{id}/cards ' , [DeckCardsController::class, 'show ' ])
48+ ->whereNumber ('id ' )
49+ ->name ('deck.cards ' );
4550});
4651
4752require __DIR__ .'/auth.php ' ;
You can’t perform that action at this time.
0 commit comments