Question: Hi guys new to laravel here. I am trying to edit my post and when i try to access the `edit` function in my controller i get this `error Property [id] does not exist on this collection instance.`

> 
> This is My route code 
> 
> 
> 

```
Route::resource('/article','PostController'); 

```

> 
> This is my Controller 
> 
> 
> 

```
public function edit(Post $post)
{

    $post = Post::all();
    return view('article.edit',compact('post'));

}

```

> 
> This is my View code 
> 
> 
> 

```
<a href="{{route('article.edit', $post->id)}}" class="btn btn-info btn-sm btn-bordred wave-light"> 
<i class="fas fa-edit"></i></a>

```

> 
> And solution ? Thanks in advance
> 
> 
>

Answer: 
you are passing `collection` to your `view` instead of single post

```
public function edit(Post $post)
{

    $post = Post::all(); // this is a collection of posts
    return view('article.edit',compact('post'));

}

```

it should be:

```
public function edit(Post $post)
{
    // here $post holds the instance of single/current post

    return view('article.edit',compact('post'));

}

```

Then in your `blade`

```
<a href="{{route('article.edit', ['post' => $post->id ])}}" class="btn btn-info btn-sm btn-bordred wave-light"> 
<i class="fas fa-edit"></i></a>

```

**Note:** Since you are passing `$post` as `instance` of the model so therefor you don't have to use `Post::find();` `laravel` will take care of that automatically at back-end

Thanks
That's because the variable `$post` holds a Laravel Collection. You have to iterate on that collection to access each post model.

```
// Returns a collection of posts model (think of 
// it as an array of posts)
$post = Post::all();

```

On your blade, use a `foreach` to iterate through each post.

**Edit**

I see that you already have an instance of post available, in that case just use this code

```
public function edit(Post $post)
{
    return view('article.edit', ["post" =>$post]);
}

```