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?