0

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 Answer 1

2

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');
Sign up to request clarification or add additional context in comments.

2 Comments

Yes, i did this , now for me that new page is displaying . But url is not chnaging . It still shows /companyCreatedSuccessfully. But i need /addMoreEmployeeDetails this URL.
HI Marcin,Please check the below thread ? stackoverflow.com/questions/26991021/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.