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 44
55use App \Models \DungeonModel ;
66use App \Models \HeroModel ;
7+ use CodeIgniter \HTTP \ResponseInterface ;
78
89class DungeonController extends BaseController
910{
@@ -28,6 +29,8 @@ public function __construct()
2829 * The $id parameter is the hero's ID, and is
2930 * passed in from the route definition as $1,
3031 * since it is the first placeholder in the route.
32+ *
33+ * @return ResponseInterface|string
3134 */
3235 public function show (int $ id )
3336 {
@@ -37,7 +40,7 @@ public function show(int $id)
3740 return redirect ()->back ()->with ('error ' , 'Dungeon not found ' );
3841 }
3942
40- echo view ('dungeon ' , [
43+ return view ('dungeon ' , [
4144 'dungeon ' => $ dungeon ,
4245 'monsters ' => $ dungeon ->monsters (3 ),
4346 ]);
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class HeroController extends BaseController
1414 * passed in from the route definition as $1,
1515 * since it is the first placeholder in the route.
1616 */
17- public function show (int $ id )
17+ public function show (int $ id ): string
1818 {
1919 // When you only need to use a model in a single place,
2020 // you can simply get a new instance here. It will use
@@ -30,10 +30,10 @@ public function show(int $id)
3030 throw new PageNotFoundException ('Hero not found ' );
3131 }
3232
33- // Display a view file , passing the variables
33+ // Return a view, passing the variables
3434 // you want to access in the view within the
3535 // second parameter.
36- echo view ('hero ' , [
36+ return view ('hero ' , [
3737 'hero ' => $ hero ,
3838 ]);
3939 }
You can’t perform that action at this time.
0 commit comments