Array Callable route |
whats up gentle Guys, I just have a silly query here,
PHP Code: $routes->match(['post','get'],'/', [\App\Controllers\Gearbox\ChangeGearController::class, 'insertGearMethod']);/*['as'=>'changegear']*/ I want to name-route this route How do I do? have tried but getting errors. Thanks Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
(07-15-2022, 08:23 AM)iRedds Wrote: What errors? Sorry for the late reply @iRedds yes! I face PHP Code: //(This woks fine but for array how to do?) PHP Code: explode(): Argument #2 ($string) must be of type string, array given I use this assoc array way so what is the best way to do this route as a named route? PHP Code: <?=base_url(route_to('login'))?> PHP Code: $routes->match(['get','post'],'login', [AuthController::class, 'login','as'=>'login']); Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
Please Read:
CodeIgniter 4 User Guide - URI Routing - Using Named Routes What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(07-16-2022, 12:33 AM)InsiteFX Wrote: Please Read: Thank @InsiteFX for your quickly reply because I know the named route as you've directed me to view the deep query I want to know for new CI 4.2 array callable route as named route PHP Code: $routes->match(['get', 'post'], 'login', [AuthController::class, 'login']); (07-16-2022, 12:48 AM)iRedds Wrote: @luckmoshy Options must be specified separately. Thank you now have got you clear Code: (Options must be specified separately) Thank you @iRedds for your great time this is what exactly I wanted so the problem solved 100% in this way PHP Code: $routes->match(['get','post'],'login', [AuthController::class, 'login'], ['as'=>'login']); Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
I didn't know we can set the same route name to different (HTTP verb) routes.
Try this:
PHP Code: $routes->match(['get', 'post'], 'login', 'AuthController::class', ['as' => 'login']); What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(07-16-2022, 11:34 PM)InsiteFX Wrote: Try this: Thanks, @InsiteFX This issue was solved PHP Code: $routes->match(['get','post'],'login', [AuthController::class, 'login'], ['as'=>'login']); Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
|
Welcome Guest, Not a member yet? Register Sign In |