Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect with id in Laravel

Tags:

php

laravel

Trying to Redirect to a route:

return Redirect::route('job_view', array('id' =>$id))
                ->with('succes','Alread Apply for this post');

Error :InvalidArgumentException in UrlGenerator.php line 314 Route [job_view] not defined.

The route Define in Web.php

Route::get('/job_view/{id}','jobseekerController@job_view');

2 Answers

In your web definition you defined Id but when you were calling the redirect to the job_view, you did not add the id to it. Do this instead

return redirect()->to('job_view/'.$id);
like image 171
decodedxclusive Avatar answered Oct 30 '25 22:10

decodedxclusive


you can pass parameter and some status like this

return Redirect::to('job_view')
->with(['id'=>$id,'succes' => 'Alread Apply for this post']);

['id'=>$id,'succes' => 'Alread Apply for this post'] thats mean you pass two parameters first id and second is succes and then you get in view like this

for id: {{$id}}

for succes: {{$succes}}

like image 30
Bilal Ahmed Avatar answered Oct 30 '25 23:10

Bilal Ahmed