0
votes

I have a controller which saves my form data and after saving that data i am trying to redirect my page to another form.But Redirection part not working form me. This is my saving controller code.

    class CompanyRegistrationController extends BaseController
    {
        public function saveAndCreateCompany()
        {
        // my code which gets form data and saves in database. 
        //After that i am trying to redirect this to another page.
        To acheive this i am trying to do this.
        App::make('AddMoreEmployeeController')->showAddMoreEmployeeDetails();
        }
    }
    // My new page code
    class AddMoreEmployeeController extends BaseController
    {
        public  function showAddMoreEmployeeDetails()
        {
        return View::make('company.addEmployee');
        }
    }
    Routes.php code
        Route::post('/companyCreatedSuccessfully', array('uses' =>     'CompanyRegistrationController@saveAndCreateCompany','as' => 'saveAndCreateCompany'));
        Route::get('/addMoreEmployeeDetails', array('uses' => 'AddMoreEmployeeController@showAddMoreEmployeeDetails','as' => 'showAddMoreEmployeeDetails'));
    
But after filling the form details I am not redirecting to "addMoreEmployeeDetails" . I am still in companyCreatedSuccessfully with blank page.But After successful save data in database i need to redirect to addMoreEmployeeDetails. Where i did mistake?
1

1 Answers

2
votes

The problem is that you only launch other controller but do nothing with its result. You need to return it:

return App::make('AddMoreEmployeeController')->showAddMoreEmployeeDetails();

and now it will work.

EDIT

As you want to change url, it seems you want to make redirection to another controller, so you should use:

return Redirect::action('AddMoreEmployeeController@showAddMoreEmployeeDetails');