lundi 21 septembre 2015

Laravel 5 - route not being redirected too

I have set up some resourceful routing with an additional route to email a PDF.

Route::model('projects.document', 'Document');
Route::resource('projects.document', 'Docs\DocumentController', ['except' => ['index', 'show']]);
Route::post('projects/{projects}/document/{document}/emailPdf', array('as' => 'projects.document.emailPdf', 'uses' => 'Docs\DocumentController@emailPdf'));

This all works fine but I am having one problem. On my projects.documents edit page, I have a modal which allows emails to be entered and then when you click send, the emails are sent to the email addresses. Once again, this all works.

My email function looks like the following

public function emailPdf(Project $project)
{
    $emailList = Input::get('email-select');
    try{
        $pdf = new DocumentPDF($orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false, $project);
        $pdf->storePdf();
        $pdf->sendEmail($emailList);
        $users = User::lists('userEmail');
        return View::make('document.edit', compact('project', 'users'));
    } catch(Exception $e) {
        var_dump("ERROR " . $e);
    }
}

When an email is sent, the modal closes, and I am still on the documents edit page like I want it to be. However, the url changes to

http://localhost:8000/projects/23/document/2/emailPdf

I know this is the route for the emailPdf function, but once an email is sent, this should go back to

http://localhost:8000/projects/23/document/2/edit

How can I get it to do this?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire