|
3 | 3 | namespace App\Controllers; |
4 | 4 |
|
5 | 5 | use App\Models\DungeonModel; |
6 | | -use App\Models\HeroModel; |
7 | 6 | use CodeIgniter\HTTP\ResponseInterface; |
8 | 7 |
|
9 | 8 | class DungeonController extends BaseController |
10 | 9 | { |
11 | 10 | /** |
12 | | - * HeroModel instance. |
| 11 | + * DungeonModel instance. |
13 | 12 | */ |
14 | | - protected $heroes; |
| 13 | + protected DungeonModel $dungeons; |
15 | 14 |
|
16 | 15 | public function __construct() |
17 | 16 | { |
18 | | - // Assign the model to $this->heroes |
| 17 | + // Assign the model to $this->dungeons |
19 | 18 | // so that it's available throughout this class |
20 | 19 | // Use the `model()` helper method to return |
21 | 20 | // a single instance of the model no matter |
22 | 21 | // how many times we call it |
23 | | - $this->heroes = model(DungeonModel::class); |
| 22 | + $this->dungeons = model(DungeonModel::class); |
24 | 23 | } |
25 | 24 |
|
26 | 25 | /** |
27 | | - * View a single hero's details. |
| 26 | + * View a single dungeon's details. |
28 | 27 | * |
29 | | - * The $id parameter is the hero's ID, and is |
| 28 | + * The $id parameter is the dungeon's ID, and is |
30 | 29 | * passed in from the route definition as $1, |
31 | 30 | * since it is the first placeholder in the route. |
32 | 31 | * |
33 | 32 | * @return ResponseInterface|string |
34 | 33 | */ |
35 | 34 | public function show(int $id) |
36 | 35 | { |
37 | | - $dungeon = $this->heroes->find($id); |
| 36 | + $dungeon = $this->dungeons->find($id); |
38 | 37 |
|
39 | 38 | if ($dungeon === null) { |
40 | 39 | return redirect()->back()->with('error', 'Dungeon not found'); |
|
0 commit comments