• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Route with http verb

#1
Hi,
This may have been answered, but as the forum search is not working I need to ask.

I am trying to redirect to a page with parameters, but not sure how to configure the redirect, the route or even if the route is necessary.

Essentially I am trying to replicate the following http://mydomain/mypage/mymethod?weekending='something' in the redirect, i.e.

PHP Code:
return redirect()->route('named_route/weekending/25-10-2020'); 


And assuming my route would look something like
PHP Code:
$routes->post('named_route/varName/varValue''myPage::myMethod/parameters'); 

which would interact with my controller
PHP Code:
class myPage extends BaseController {
    
    public function 
index() {
    
         
//This does something
    }

    
    public function 
myMethod() {
    
        if(
$this->request->getGetPost('weekending')) {
            
            
//this does something else    
            
            
}else{
            return redirect()->route('404');
            }
    }

Reply

#2
Hi,

I recently posted for help with redirect and routing (https://forum.codeigniter.com/thread-77734.html).

Unfortunately it does not seem possible to configure a redirect with parameters that points to a route that interprets the parameters

i.e.

PHP Code:
redirect()->route('named_route/weekending/25-10-2020'); 
or
PHP Code:
redirect()->route('named_route?weekending=25-10-2020'); 
or
PHP Code:
redirect()->to('named_route?weekending=25-10-2020'); 
where a route is (add, get, post, etc)

i.e

PHP Code:
$routes->get('named_route/varName/varValue''myPage::myMethod/parameters'); 
As a workaround I've manually set _ci_previous_url to use with redirect()->back(). It's not ideal, but it is a work around that suits the purpose
PHP Code:
$sessUpdate = [
    
'_ci_previous_url'  => base_url('myPage/myMethod?weekending='.$week_ending)
];

$this->session->set($sessUpdate); 
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.