16760

UrlGenerationException (Missing required parameters for [Route])

I don't know where this error came from it says. I got this error when I tried to update my records. It works properly and updating into my database but getting this error. It says that that missed something in my parameter. I think my error is return redirect()->route('account.show'); when I tried to redirect to my <strong>show</strong> view after updating. But when I redirect to other works fine. Any opinions?

Missing required parameters for [Route: account.show] [URI: show/{id}].

I have 3 blade template. <strong>search</strong>, <strong>edit</strong> and <strong>show</strong>.

search.blade.php - To show all the records.

@foreach ($result as $row) <tr class = "success"> <td>{{ $row->id }}</td> <td>{{ $row->first_name }}</td> <td>{{ $row->last_name }}</td> <td>{{ $row->middle_name }}</td> <td>{{ $row->email }}</td> <td>{{ $row->username }}</td> <td> <a href = "{{ route ('account.show', $row->id) }}"><button type = "submit" class = "btn btn-info">View</button></a> <a href = "{{ route ('account.edit', $row->id) }}"><button type = "submit" class = "btn btn-warning">Edit</button></a> <a href = "{{ route ('result.destroyEmployee', $row->id) }}"><button type = "submit" class = "btn btn-danger">Archive</button></a> </td> </tr> @endforeach

edit.blade.php - Here where I got the error after hitting the submit button which is <strong>Save</strong>

<div class = "col-md-6"> <form class = "form-vertical" role = "form" method = "post" action = "{{ route ('account.edit', $result->id) }}"> <h3>Edit Employee</h3> <hr> <div class = "form-group"> <label for = "email" class = "control-label">Email Address</label> <input type = "text" name = "email" class = "form-control" value = "{{ $result->email }}"> </div> <div class = "form-group"> <label for = "username" class = "control-label">Username</label> <input type = "text" name = "username" class = "form-control" value = "{{ $result->username }}"> </div> <div class = "form-group"> <button type = "submit" class = "btn btn-success">Save</button> </div> <input type = "hidden" name = "_token" value = "{{ Session::token() }}"> </form>

show.blade.php - Textfield's will just place the value of the records.

<div class = "col-md-6"> <form class = "form-vertical" role = "form" method = "post" action = "{{ route ('account.show', $result->id) }}"> <h3>View Employee</h3> <hr> <div class = "form-group"> <label for = "email" class = "control-label">Email Address</label> <input type = "text" name = "email" class = "form-control" placeholder = "{{ $result->email }}" readonly> </div> <div class = "form-group"> <label for = "username" class = "control-label">Username</label> <input type = "text" name = "username" class = "form-control" placeholder = "{{ $result->username }}" readonly> </div> <input type = "hidden" name = "_token" value = "{{ Session::token() }}"> </form>

Routes:

//READ Route::get('/search', [ 'uses' => '\App\Http\Controllers\AccountController@getEmployee', 'as' => 'account.search', ]); //SHOW Route::get('/show/{id}', [ 'uses' => 'AccountController@showEmployee', 'as' => 'account.show', ]); //EDIT Route::get('/edit/{id}', [ 'uses' => '\App\Http\Controllers\AccountController@editEmployee', 'as' => 'account.edit', ]); //UPDATE Route::post('/edit/{id}', [ 'uses' => '\App\Http\Controllers\AccountController@updateEmployee', 'as' => 'account.edit', ]);

Answer1:

Try to change this:

<form class = "form-vertical" role = "form" method = "post" action = "{{ route ('account.show', $result->id) }}">

To:

<form class = "form-vertical" role = "form" action="{{ url('edit/'. $result->id) }}" method="POST">

Then you have to pass the route parameters as second argument to route. Something like this: return redirect()->route('account.show', [$id])

*I would recommend you to use laravel collective form: https://laravelcollective.com/

With laravel collective you can do something like this:

{!! Form::open(array('route' => array('account.show', $result->id))) !!}

Recommend

  • Getting null fields in crystal reports
  • Updating data in phpMyAdmin
  • how to pass parameter to php function and call in html
  • Conditional Validation in Ecto for OR - 1 of 2 fields is required
  • Mysql optimization based on explain
  • How do I exit a series of If / else conditions in a mysql trigger?
  • Strong Parameters - Can't Access the Deeply-Nested Attributes
  • Android ContentProvider applyBatch not saving all contact data
  • How to use ctype_alpha with UTF-8
  • Getting data from database using HQL
  • redirect user after update in class based view in django
  • Yii2 Login with database
  • How to open html table in xls on click of a button
  • how to get username into sql trigger when multiple users signed on from asp membership
  • Extract All Possible Paths from Expression-Tree and evaluate them to hold TRUE
  • XSLT foreach repeating nodes to flat
  • List images(01.png) and descriptions(01.txt) from directory
  • nonblocking BIO_do_connect blocked when there is no internet connected
  • How do I access an unhandled exception in an MVC Error view?
  • Custom validator control occupying space even though display set to dynamic
  • Email verification using google app script and google forms
  • D3 nodes and links from JSON with nested arrays of children
  • Get data from AJAX - How to
  • Email format validation in mvc3 view
  • Bug in WPF DataGrid
  • sending/ receiving email in Java
  • Upload files with Ajax and Jquery
  • Do I've to free mysql result after storing it?
  • php design question - will a Helper help here?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • A cron job substitute?
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • AngularJs get employee from factory
  • Java static initializers and reflection
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Authorize attributes not working in MVC 4
  • unknown Exception android
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app