File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use App \Models \DungeonModel ;
6
6
use App \Models \HeroModel ;
7
+ use CodeIgniter \HTTP \ResponseInterface ;
7
8
8
9
class DungeonController extends BaseController
9
10
{
@@ -28,6 +29,8 @@ public function __construct()
28
29
* The $id parameter is the hero's ID, and is
29
30
* passed in from the route definition as $1,
30
31
* since it is the first placeholder in the route.
32
+ *
33
+ * @return ResponseInterface|string
31
34
*/
32
35
public function show (int $ id )
33
36
{
@@ -37,7 +40,7 @@ public function show(int $id)
37
40
return redirect ()->back ()->with ('error ' , 'Dungeon not found ' );
38
41
}
39
42
40
- echo view ('dungeon ' , [
43
+ return view ('dungeon ' , [
41
44
'dungeon ' => $ dungeon ,
42
45
'monsters ' => $ dungeon ->monsters (3 ),
43
46
]);
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class HeroController extends BaseController
14
14
* passed in from the route definition as $1,
15
15
* since it is the first placeholder in the route.
16
16
*/
17
- public function show (int $ id )
17
+ public function show (int $ id ): string
18
18
{
19
19
// When you only need to use a model in a single place,
20
20
// you can simply get a new instance here. It will use
@@ -30,10 +30,10 @@ public function show(int $id)
30
30
throw new PageNotFoundException ('Hero not found ' );
31
31
}
32
32
33
- // Display a view file , passing the variables
33
+ // Return a view, passing the variables
34
34
// you want to access in the view within the
35
35
// second parameter.
36
- echo view ('hero ' , [
36
+ return view ('hero ' , [
37
37
'hero ' => $ hero ,
38
38
]);
39
39
}
You can’t perform that action at this time.
0 commit comments