From a319f074854bac9604679b38e23c46ffdbc4474f Mon Sep 17 00:00:00 2001 From: Andy Newhouse Date: Thu, 25 Apr 2024 14:31:16 -0500 Subject: [PATCH] Add showing tricks --- app/Http/Controllers/TrickController.php | 4 +++- resources/views/tricks/show.blade.php | 13 +++++++++++++ routes/web.php | 2 ++ tests/Feature/TrickTest.php | 7 +++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 resources/views/tricks/show.blade.php diff --git a/app/Http/Controllers/TrickController.php b/app/Http/Controllers/TrickController.php index 4c9889f..f61e6b0 100644 --- a/app/Http/Controllers/TrickController.php +++ b/app/Http/Controllers/TrickController.php @@ -35,7 +35,9 @@ public function store(Request $request) public function show(Trick $trick) { - // + return view('tricks.show', [ + 'trick' => $trick, + ]); } public function edit(Trick $trick) diff --git a/resources/views/tricks/show.blade.php b/resources/views/tricks/show.blade.php new file mode 100644 index 0000000..9745f1f --- /dev/null +++ b/resources/views/tricks/show.blade.php @@ -0,0 +1,13 @@ + + +

+ {{ $trick->name }} +

+
+ +
+
+ +
+
+
diff --git a/routes/web.php b/routes/web.php index 248e731..409c3f2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -22,4 +22,6 @@ Route::delete('profile', [ProfileController::class, 'destroy'])->name('profile.destroy'); }); +Route::get('tricks/{trick}', [TrickController::class, 'show'])->name('tricks.show'); + require __DIR__ . '/auth.php'; diff --git a/tests/Feature/TrickTest.php b/tests/Feature/TrickTest.php index eede142..e457748 100644 --- a/tests/Feature/TrickTest.php +++ b/tests/Feature/TrickTest.php @@ -55,6 +55,13 @@ }); // Show +test('can view trick', function () { + $trick = Trick::factory()->create(['name' => 'How to make a trick']); + + $this->get(route('tricks.show', $trick)) + ->assertStatus(200) + ->assertSee('How to make a trick'); +}); // Edit test('can view edit trick page', function () {