Chairuman
Chairuman

Reputation: 136

"Too few arguments to function App\Http\Controllers\Backend\BlogController::edit(), 0 passed and exactly 1 expected"

can anybody help me with this error? Here my complete route

Route::resource('/blog/post', 'Backend\BlogController');

this is my edit function on BlogController

public function edit($id)
{
    $post = Post::findOrFail($id);
    return view("backend.blog.edit", compact('post'));
}

and this my button

<a href="{{ route('post.edit', $post->id) }}" class="btn btn-xs btn-default">
    <i class="fa fa-edit"></i>
</a>

Upvotes: 1

Views: 230

Answers (1)

matiit
matiit

Reputation: 8017

While generating a button, a correct way, according to the documentation is:

<a href="{{ route('post.edit', ['id' => $post->id]) }}" class="btn btn-xs btn-default">
    <i class="fa fa-edit"></i>
</a>

Note passing an array of options as a second argument.

Upvotes: 1

Related Questions