Welcome Guest, Not a member yet? Register   Sign In
redirecting from another method
#1

butHello, all,
I have the following question. In my controller (Service) I easily redirect with:

PHP Code:
return redirect()->to('http://' $_SERVER['HTTP_HOST'] . $this->data['router']['edit'] . $Id '?add=1'); 


But when I call some method from my controller and this method is defined in the BaseController for example, the redirection does not work.
Here is a fragment from my code, In my controller:
PHP Code:
class Service extends BaseController
{
    public function edit()
    {
        $this->editData();
    }


And here is the editData() method in the BaseController

PHP Code:
protected function editData($Id)
    {

        if ($this->request->getMethod() === 'post') {
            if ($Id) {
                $res $this->saveData($Id);
                $this->data['res'] = ['type' => 1'mess' => ($res) ? lang($this->data['lang'] . '.mess.ok.edit') : lang($this->data['lang'] . '.mess.err.edit')];
            } else {
                $Id $this->saveData();
                if ($Id) {
                    return redirect()->to('http://' $_SERVER['HTTP_HOST'] . $this->data['router']['edit'] . $Id '?add=1');
                } else {
                    $this->data['res'] = ['type' => 0'mess' => lang($this->data['lang'] . '.mess.err.add')];
                }
            }
        }
    

If I change it to "return editData()" in my edit() method it works, but this does not works for me. So is there a way to redirect directly from the editData method?
Reply


Messages In This Thread
redirecting from another method - by vgrigorov - 08-16-2022, 01:57 AM
RE: redirecting from another method - by iRedds - 08-16-2022, 04:14 PM
RE: redirecting from another method - by kenjis - 08-16-2022, 04:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB